UIView随手指的移动
2013-06-07 14:15
211 查看
#import <UIKit/UIKit.h> @interface zzUIView : UIView { CGPoint beginPoint; } @property (nonatomic) BOOL dragEnable; @end
#import "zzUIView.h" @implementation zzUIView @synthesize dragEnable; - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { // Initialization code } return self; } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { if (!dragEnable) { return; } UITouch *touch = [touches anyObject]; beginPoint = [touch locationInView:self]; } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { if (!dragEnable) { return; } UITouch *touch = [touches anyObject]; CGPoint nowPoint = [touch locationInView:self]; float offsetX = nowPoint.x - beginPoint.x; float offsetY = nowPoint.y - beginPoint.y; self.center = CGPointMake(self.center.x + offsetX, self.center.y + offsetY); } @end
相关文章推荐
- UIView随手指的移动
- IOS学习之路(二十五)UIView动画,弹出后移动然后消失
- android:View随手指的移动而移动
- uiview的UIEvent事件通过UIEvent来移动
- Android从基础做起——自定义View(随手移动的小球)
- 鼠标移动UIview 位置随着鼠标改变
- UIView动画---移动与变形
- 移动UIView的坐标
- 3 随手移动的小球。。。基于回调的事件
- ios-day17-01(UIView的拖拽(跟随手指移动))
- 移动UIView的坐标
- UIView动画animation 水平移动UILabel
- IOS-UIView的移动
- UIView分类之动画移动效果
- UIView视图移动,抖动效果,定时器,动画block
- AS移动开发 随手记 string类型转换int类型
- UIView动画移动效果
- UIView动画【渐入alpha、淡出、移动frame、缩放transform、旋转transform rotation】
- iOS 为移动中的UIView(UIButton )添加点击事件
- IOS成长之路-使UIView视图缓慢的移动