UIPanGestureRecognizer UIScreenEdgePanGestureRecognizer
2014-09-22 17:03
274 查看
Configuring the Gesture Recognizer
@property(nonatomic) NSUInteger maximumNumberOfTouches//The maximum number of fingers that can be touching the view for this gesture to be recognized. @property(nonatomic) NSUInteger minimumNumberOfTouches//The minimum number of fingers that can be touching the view for this gesture to be recognized.
Tracking the Location and Velocity of the Gesture
- (CGPoint)translationInView:(UIView *)view//The translation of the pan gesture in the coordinate system of the specified view.平移的距离。设置后速度为0. - (void)setTranslation:(CGPoint)translation inView:(UIView *)view//设置平移的距离 - (CGPoint)velocityInView:(UIView *)view//速度。 which is expressed in points per second.
例子
方法1:CGFloat translationX = [pan translationInView:self.view].x; pan.view.center = CGPointMake(pan.view.center.x+translationX, pan.view.center.y); [pan setTranslation:CGPointZero inView:self.view];
方法2:
CGPoint translation = [recognizer translationInView:recognizer.view]; case UIGestureRecognizerStateBegan: { [recognizer setTranslation:CGPointMake(recognizer.view.frame.origin.x, 0) inView:recognizer.view]; break; } case UIGestureRecognizerStateChanged: { [recognizer.view setTransform:CGAffineTransformMakeTranslation(MAX(0,translation.x), 0)]; [self statusBarView].transform = recognizer.view.transform; break; }
目前看来,translationInView的参数是attach的view还是其父view关系不大。每次的translation都是与上次的叠加。因此如果每次设置为0,则累加坐标即可。否则要用setTransform。
UIScreenEdgePanGestureRecognizer
AUIScreenEdgePanGestureRecognizerlooks for panning (dragging) gestures that start near an edge of the screen. The system uses screen edge gestures in some cases to initiate view controller transitions. You can use this class to replicate the same gesture behavior for your own actions.
@property(readwrite, nonatomic, assign) UIRectEdge edges
The edges you specify are always relative to the app’s current interface orientation. This behavior ensures that the gestures always occur from the same place in your user interface, regardless of the device’s current orientation.
UIRectEdge的值如下:
typedef enum : NSUInteger { UIRectEdgeNone = 0, UIRectEdgeTop = 1 << 0, UIRectEdgeLeft = 1 << 1, UIRectEdgeBottom = 1 << 2, UIRectEdgeRight = 1 << 3, UIRectEdgeAll = UIRectEdgeTop | UIRectEdgeLeft | UIRectEdgeBottom | UIRectEdgeRight } UIRectEdge;
相关文章推荐
- 使用UIScreenEdgePanGestureRecognizer写iOS7侧边栏
- 【iOS 7】使用UIScreenEdgePanGestureRecognizer实现swipe to pop效果
- UISlider和UIScreenEdgePanGestureRecognizer和简单运用,包括滑动时颜色变化,滑动按钮以及Slider按钮颜色设置
- 【iOS 7】使用UIScreenEdgePanGestureRecognizer实现swipe to pop效果
- UiSlider,UISegmentedControl和UIScreenEdgePanGestureRecognizer(手势:左划屏)
- 使用UIScreenEdgePanGestureRecognizer写iOS7侧边栏
- 记录一下UIScreenEdgePanGestureRecognizer使用问题
- 【iOS 7】使用UIScreenEdgePanGestureRecognizer实现swipe to pop效果
- 手势 UIScreenEdgePanGestureRecognizer 屏幕边缘手势
- UIScreenEdgePanGestureRecognizer无法响应/失效
- UI ⼿势识别器UIScreenEdgePanGestureRecognizer
- Objective-C-UI控件学习之UIScreenEdgePanGestureRecognizer
- iOS添加边缘手势( UIScreenEdgePanGestureRecognizer)实现侧滑效果
- IOS 的 7 中手势的介绍 和详细使用(UIGestureRecognizer) UIScreenEdgePanGestureRecognizer
- 使用UIScreenEdgePanGestureRecognizer写iOS7侧边栏
- UIScreenEdgePanGestureRecognizer 边缘触发手势 MVC模式下实现
- 25.手势识别之UIScreenEdgePanGestureRecognizer
- iOS开发-UIScreenEdgePanGestureRecognizer实战
- 同时响应iOS开发中UIPanGestureRecognizer跟UITableView的拖动事件的解决方法
- 解决interactivePopGestureRecognizer与UIPanGestureRecognizer冲突