iOS滑动手势UIPanGestureRecognizer 注意事项
Posted 懒猫口米
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了iOS滑动手势UIPanGestureRecognizer 注意事项相关的知识,希望对你有一定的参考价值。
添加滑动手势
//添加滑块
UIPanGestureRecognizer *recognizerA = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)];
[recognizerA setMaximumNumberOfTouches:1];
//滑块大小
_AView = [[UIView alloc] initWithFrame:CGRectMake(0,0, 100,150)];
[_AView addGestureRecognizer:recognizerA];
/**
* @brief 滑动模块
*/
#pragma mark --滑动模块
- (IBAction)handlePan:(UIPanGestureRecognizer *)recognizer {
//松开手指时判断滑动趋势让其计算滑动位子
if (recognizer.state == UIGestureRecognizerStateEnded) {
[self updateRelationships];
}
}
/**
* @brief 滑动大小
*/
#pragma mark --滑动大小
-(void)updateRelationships{
NSLog(@"update-CGFloat_x::%f",AView.frame.origin.x);
NSLog(@"update-CGFloat_x::%f",AView.frame.origin.y);
}
以上是关于iOS滑动手势UIPanGestureRecognizer 注意事项的主要内容,如果未能解决你的问题,请参考以下文章