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添加长按复制功能的方法,这里我 ...
随机推荐
- 【CentOS】又是一篇Shell
一.Shell 1.Shell脚本的格式 #!/bin/bash 或者是 #!/bin/sh 开头 ,这是用于解析脚本的工具 2.执行脚本的方法 (1)bash filename 或者是sh file ...
- c++2008 并行配置文件和获取字典的所有key的方法
1 需要 在官网 下载对应的执行包... 2, # !/usr/bin/python3.4 # -*- coding: utf-8 -*- b = { 'video':0, 'music':23 } ...
- 12 自定义标签/JSTL标签库/web国际化/java web之设计模式和案例
EL应用 自定义一个标签,实现两个字符串的相加 1回顾 1.1servlet生命周期 init(ServletConfig) service ...
- mac系统下mysql开机启动总是3307
修改了mysql的my.cnf可还是不行,启动后就是3307,必须关掉再启动. 觉得可能是mac系统在哪里写死了开机启动项. http://queforum.com/mysql/1012987-mys ...
- BZOJ2527: [Poi2011]Meteors
补一发题解.. 整体二分这个东西,一开始感觉复杂度不是很靠谱的样子 问了po姐姐,说套主定理硬干.. #include<bits/stdc++.h> #define ll long lon ...
- ZeroMQ接口函数之 :zmq_plain - 明文认证
ZeroMQ 官方地址 :http://api.zeromq.org/4-2:zmq_plain zmq_plain(7) ØMQ Manual - ØMQ/4.1.0 Name zmq_plain ...
- ZeroMQ接口函数之 :zmq_ipc – ZMQ本地进程间通信传输协议
ZeroMQ API 目录 :http://www.cnblogs.com/fengbohello/p/4230135.html ——————————————————————————————————— ...
- csipsimple 出现单通情况
今天在测试voip电话时,突然打不通了和windows端也不通,boss发怒了. 经过排查,发现设置G729编码 //设置G729编码 prefs.setCodecPriority("g72 ...
- java.lang.NoClassDefFoundError: javax/el/ELResolver 问题解决
HTTP Status 500 - java.lang.NoClassDefFoundError: javax/el/ELResolver type Exception report message ...
- 立flag
lixintong这半年来一直浪啊浪啊都不认真做题!!!!!!简直是太堕落啦!!lixintong非常讨厌这样的lixintong !!! 鉴于lixintong NOIP 完全爆炸啦! lixint ...