iOS,手势识别简单使用
#import "ViewController.h"
@interface ViewController ()
@property (nonatomic,strong) UIButton *gesturesBtn;
@end
@implementation ViewController
@synthesize gesturesBtn=_gesturesBtn;
- (void)viewDidLoad {
[super viewDidLoad];
[self.view setBackgroundColor:[UIColor whiteColor]];
self.navigationItem.title=@"手势测试";
_gesturesBtn=[[UIButton alloc] initWithFrame:CGRectMake(self.view.frame.size.width*0.35, self.view.frame.size.height*0.4, self.view.frame.size.width*0.3, self.view.frame.size.height*0.1)];
[_gesturesBtn setBackgroundColor:[UIColor blueColor]];
[_gesturesBtn.layer setCornerRadius:5.0];
[_gesturesBtn.layer setBorderWidth:0.5];
[_gesturesBtn setTitle:@"GesturesTest" forState:UIControlStateNormal];
[_gesturesBtn setTintColor:[UIColor blackColor]];
//慢速滑动
UIPanGestureRecognizer *panLeft=[[UIPanGestureRecognizeralloc]initWithTarget:self action:@selector(panLeftAction:)];
[self.view addGestureRecognizer:panLeft];
//单击手势
UITapGestureRecognizer *tapGes=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
//点按次数
[tapGes setNumberOfTapsRequired:1];
//点按手指数量
[tapGes setNumberOfTouchesRequired:1];
//把手势加到该按钮视图上
[_gesturesBtn addGestureRecognizer:tapGes];
[self.view addSubview:_gesturesBtn];
}
//慢速滑动手势响应事件
-(void)panLeftAction:(UISwipeGestureRecognizer *)sender{
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"提示" message:@"慢滑动"delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
//点按手势响应事件
-(void)tapAction:(UITapGestureRecognizer *)sender{
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"提示" message:@"点按手势" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
@end
iOS,手势识别简单使用的更多相关文章
- iOS手势识别的详细使用(拖动,缩放,旋转,点击,手势依赖,自定义手势)
iOS手势识别的详细使用(拖动,缩放,旋转,点击,手势依赖,自定义手势) 1.UIGestureRecognizer介绍 手势识别在iOS上非常重要,手势操作移动设备的重要特征,极大的增加 ...
- ios iOS手势识别的详细使用(拖动,缩放,旋转,点击,手势依赖,自定义手势)
iOS手势识别的详细使用(拖动,缩放,旋转,点击,手势依赖,自定义手势) 转自容芳志大神的博客:http://www.cnblogs.com/stoic/archive/2013/02/27/2940 ...
- iOS上简单推送通知(Push Notification)的实现
iOS上简单推送通知(Push Notification)的实现 根据这篇很好的教程(http://www.raywenderlich.com/3443/apple-push-notification ...
- iOS CAReplicatorLayer 简单动画
代码地址如下:http://www.demodashi.com/demo/11601.html 写在最前面,最近在看学习的时候,偶然间发现一个没有用过的Layer,于是抽空研究了下,本来应该能提前记录 ...
- iOS之简单瀑布流的实现
iOS之简单瀑布流的实现 前言 超简单的瀑布流实现,这里说一下笔者的思路,详细代码在这里. 实现思路 collectionView能实现各中吊炸天的布局,其精髓就在于UICollectionVie ...
- UIGestureRecognizer ios手势识别温习
1.UIGestureRecognizer介绍 手势识别在iOS上非常重要,手势操作移动设备的重要特征,极大的增加了移动设备使用便捷性. iOS系统在3.2以后,为方便开发这使用一些常用的手势,提供了 ...
- 【转】iOS手势识别的详细使用(拖动,缩放,旋转,点击,手势依赖,自定义手势) -- 不错不错
原文网址:http://blog.csdn.net/totogo2010/article/details/8615940 1.UIGestureRecognizer介绍 手势识别在iOS上非常重要,手 ...
- 介绍一些实用的IOS手势识别库 (COCOS2D)
http://www.supersuraccoon-cocos2d.com/zh/2012/11/14/introduction-to-some-great-ios-gesture-recogniti ...
- ios label 简单的长按复制文本信息
在iOS开发过程中,有时候会用到UILabel展示的内容,那么就设计到点击UILabel复制它上面展示的内容的功能,也就是Label长按复制功能.网上有很多种给Label添加长按复制功能的方法,这里我 ...
随机推荐
- 【淘淘】Spring整合Quartz框架
我在外面工作实习的时候,我们做的项目是一个日报子系统,也就是定时定点为公司生成一些报表数据还有一些数据反馈.这时候我们会经常用到定时任务,比如每天凌晨生成前天报表,每一小时生成汇总数据等等.当时,我做 ...
- 与IE奋战的血泪史
IE6下font-size会撑高元素,也就是说IE6下元素的最小高度为font-size的高度(蛋疼) IE6不支持两个class 例如 .a.b,类名不支持下划线开头 通过js设置样式带下划线的样式 ...
- 转:AngularJS的Filter用法详解
Filter简介 Filter是用来格式化数据用的. Filter的基本原型( '|' 类似于Linux中的管道模式): {{ expression | filter }} Filter可以被链式使用 ...
- php_codesninffer phpcs用法学习使用:
18:34 2016/1/12php_codesninffer phpcs用法学习使用:可以加一个参数设置结果输出为各种格式:如source格式:$ phpcs -s --report=source ...
- 初识genymotion安装遇上的VirtualBox问题
想必做过Android开发的都讨厌那慢如蜗牛的 eclipse原生Android模拟器吧! 光是启动这个模拟器都得花上两三分钟,慢慢的用起来手机来调试,但那毕竟不是长久之计,也确实不方便,后来知道了g ...
- 转:ibatis的cacheModel
转:ibatis的cacheModel cachemodel是ibatis里面自带的缓存机制,正确的应用能很好提升我们系统的性能. 使用方法:在sqlmap的配置文件中加入 <cacheMode ...
- arcmap配置的mxd慢的问题
http://www.360doc.com/content/13/0220/09/3046928_266688511.shtml
- Coreseek 安装指南
Coreseek 中文官网:http://www.coreseek.cn/ Sphinx0.9.9 中文手册:http://www.coreseek.cn/docs/coreseek_3.2-sphi ...
- 一些关于Viewport与device-width的东西~
进行移动web开发已经有一年多的时间了,期间遇到了一些令人很困惑的东西.比如: 我们经常使用的<meta name="viewport" content="widt ...
- 更换app开发者账号
在开源中国上面有一个答案,http://www.oschina.net/question/2307266_237220 下面是我的执行步骤 首先在iTunes Connect中找到要更换开发者账号的a ...