文章搬運來源:blog.csdn.net/Calvin_zhou…面試
做者:PGzxc(若有侵權,聯繫做者,當即刪除)markdown
對iOS開發感興趣,能夠看一下做者的iOS交流羣:812157648,你們能夠在裏面吹水、交流相關方面的知識,羣裏還有我整理的有關於面試的一些資料,歡迎你們加羣,你們一塊兒開車app
-(void)touchBegan:(NSSet *)touches withEvent:(UIEvent *)event;
-(void)touchMoved:(NSSet *)touches withEvent:(UIEvent *)event;
-(void)touchEnded:(NSSet *)touches withEvent:(UIEvent *)event;
-(void)touchCancelled:(NSSet *)touches withEvent:(UIEvent *)event;
複製代碼
-(void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event;
-(void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event;
-(void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event;
複製代碼
-(void)remoteControlReceivedWithEvent:(UIEvent *)event;
複製代碼
@property(nonatomic,readonly,retain)UIWindow *window;
複製代碼
@property(nonatomic,readonly,retain)UIView *view;
複製代碼
@property(nonatomic,readonly)NSUInteger tapCount;
複製代碼
@property(nonatomic,readonly)NSTimeInterval timestamp;
複製代碼
@property(nonatomic,readonly)UITouchPhase phase;
複製代碼
typedef NS_ENUM(NSInteger, UITouchPhase) {
UITouchPhaseBegan, // whenever a finger touches the surface.
UITouchPhaseMoved, // whenever a finger moves on the surface.
UITouchPhaseStationary, // whenever a finger is touching the surface but hasn't moved since the previous event.
UITouchPhaseEnded, // whenever a finger leaves the surface.
UITouchPhaseCancelled,
複製代碼
//觸摸移動
- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
UITouch *touch=[touches anyObject];
//獲取當前的位置
CGPoint current=[touch locationInView:self];
CGPoint pre=[touch previousLocationInView:self];
//x軸的偏移量
CGFloat offsetX=current.x-pre.x;
CGFloat offsetY=current.y-pre.y;
CGPoint center=self.center;
center.x+=offsetX;
center.y+=offsetY;
self.center=center;
//NSLog(@"%d",touch.phase);
//NSLog(@"%s---%p",__func__,touch);
}
複製代碼