觸摸開(kāi)始
// 當(dāng)手指開(kāi)始觸摸view
// NSArray,字典,NSSet(無(wú)序)
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"%ld", touches.count);
NSLog(@"%s",__func__);
}
觸摸移動(dòng)的時(shí)候調(diào)用
// 當(dāng)手指在view上移動(dòng)的時(shí)候
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
// 獲取當(dāng)前點(diǎn)
CGPoint currentPoint = [touch locationInView:self];
// 獲取上一個(gè)點(diǎn)
CGPoint previousPoint = [touch previousLocationInView:self];
// 獲取 X 軸的偏移量
CGFloat x = currentPoint.x - previousPoint.x;
// 獲取 Y 軸的偏移量
CGFloat y = currentPoint.y - previousPoint.y;
// 修改 view 的位置
self.transform = CGAffineTransformTranslate(self.transform, x, y);
}
觸摸事件被打斷的時(shí)候
// 當(dāng)觸摸事件被打斷的時(shí)候調(diào)用(電話打入)
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
}
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者