【发布时间】:2011-09-21 05:45:03
【问题描述】:
如何使应用程序中的按钮像操作系统主屏幕一样可拖放?
到目前为止,我看到了两种制作动画的方法——
- 通过
UIView方法为frame、bounds、centre、transform和alpha提供动画 - 使用我不熟悉的
Core Animation。
我能够移动UIImageView 对象。这同样适用于移动UIButton 对象吗?
我移动 UIImageView 对象的代码是:
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
imageView.center = location;
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
[self touchesBegan:touches withEvent:event];
}
我可以使用相同的代码来移动按钮吗?
【问题讨论】:
标签: objective-c ios cocoa-touch ios4 core-animation