IOS 手势之左右滑动
来源:互联网 发布:ipv6免费上网软件 编辑:程序博客网 时间:2024/05/21 20:21
1. 在"ViewController.h"中增加两个手势property.
1
2
@property (nonatomic, strong) UISwipeGestureRecognizer *leftSwipeGestureRecognizer;
@property (nonatomic, strong) UISwipeGestureRecognizer *rightSwipeGestureRecognizer;
2.在"ViewController.m"文件中的"ViewDidLoad"方法中增加如下代码:
1
2
3
4
5
6
7
8
self.leftSwipeGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipes:)];
self.rightSwipeGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipes:)];
self.leftSwipeGestureRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;
self.rightSwipeGestureRecognizer.direction = UISwipeGestureRecognizerDirectionRight;
[self.view addGestureRecognizer:self.leftSwipeGestureRecognizer];
[self.view addGestureRecognizer:self.rightSwipeGestureRecognizer];
3.并在"ViewController.m"中增加如下方法;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
- (void)handleSwipes:(UISwipeGestureRecognizer *)sender
{
if
(sender.direction == UISwipeGestureRecognizerDirectionLeft) {
CGPoint labelPosition = CGPointMake(self.swipeLabel.frame.origin.x - 100.0, self.swipeLabel.frame.origin.y);
self.swipeLabel.frame = CGRectMake( labelPosition.x , labelPosition.y , self.swipeLabel.frame.size.width, self.swipeLabel.frame.size.height);
self.swipeLabel.text = @
"尼玛的, 你在往左边跑啊...."
;
}
if
(sender.direction == UISwipeGestureRecognizerDirectionRight) {
CGPoint labelPosition = CGPointMake(self.swipeLabel.frame.origin.x + 100.0, self.swipeLabel.frame.origin.y);
self.swipeLabel.frame = CGRectMake( labelPosition.x , labelPosition.y , self.swipeLabel.frame.size.width, self.swipeLabel.frame.size.height);
self.swipeLabel.text = @
"尼玛的, 你在往右边跑啊...."
;
0 0
- IOS 手势之左右滑动
- IOS 手势之左右滑动UISwipeGestureRecognizer
- iOS 手势之左右滑动UISwipeGestureRecognizer
- ios 左右滑动手势
- android 手势左右滑动
- android手势左右滑动
- android 手势左右滑动
- android 手势左右滑动
- android手势左右滑动
- iOS手势之 响应上下左右滑动手势
- iOS:点击按钮或者手势控制界面左右滑动
- uitableviewcell的左右滑动手势
- 使用手势模拟左右滑动
- iOS之UITableViewCell左右滑动效果
- iOS UIScrollView左右滑动手势与返回手势冲突的解决办法
- iOS之手势滑动返回功能
- iOS 上下左右滑动手势
- ios添加滑动手势
- Add Binary —— Leetcode(重做)
- 陈怡暖:市场空头回吐,银价支撑反弹
- 称砝码问题
- Java并发编程——待完善
- 让TEXT朗读起来
- IOS 手势之左右滑动
- iOS 开发小技巧
- VideoCapture之grab()和retrieve()
- 关于错误的总结。。
- STL库---优先队列
- FragmentActivity 长期后台被放置问题
- redis 简单优化
- 安卓界面所有控件整体缩放
- flexibility of openstack(2)