ios 中手势用法
pan拖动手势
- (void)viewDidLoad
{
[super viewDidLoad];
[self Pan];
// Do any additional setup after loading the view, typically from a nib.
} #pragma mark -拖动手势Pan
-(void)Pan{
UIView *view=[[UIView alloc] initWithFrame:CGRectMake(, , , )];
view.backgroundColor=[UIColor redColor];
[self.view addSubview:view];
[view release]; UIPanGestureRecognizer *pin=[[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(pin:)];
[view addGestureRecognizer:pin];
[pin release];
} -(void)pin:(UIPanGestureRecognizer*)pin{
//得到pin移动的位置,向左拖动是左拖动x为负数,向上拖动y为负数,向下拖动y为整数,向右边拖动为x为整数
CGPoint point= [pin translationInView:self.view];
NSLog(@"%@",NSStringFromCGPoint(point));
//手势结束的状态
if(pin.state==UIGestureRecognizerStateEnded){
NSLog(@"手指已离开屏幕,手势结束");
} //注意一定要加下面一句 ,清除手势为原来坐标
[pin setTranslation:CGPointZero inView:self.view]; }
缩放手势
- (void)viewDidLoad
{
[super viewDidLoad];
[self Princh];
// Do any additional setup after loading the view, typically from a nib.
} #pragma mark -Princh
-(void)Princh{
UIView *view=[[UIView alloc] initWithFrame:CGRectMake(, , , )];
view.backgroundColor=[UIColor redColor];
[self.view addSubview:view];
UIPinchGestureRecognizer *pinch=[[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinch:)];
[view addGestureRecognizer:pinch];
[pinch release]; [view release]; } -(void)pinch:(UIPinchGestureRecognizer *)pin{ //主要属性
CGFloat scale= pin.scale;
pin.view.transform=CGAffineTransformScale(pin.view.transform, pin.scale, pin.scale);
if(pin.state==UIGestureRecognizerStateEnded){ }
scale=; }
缩放
[self Rotaion];
// Do any additional setup after loading the view, typically from a nib.
} #pragma mark -Princh
-(void)Rotaion{
UIView *view=[[UIView alloc] initWithFrame:CGRectMake(, , , )];
view.backgroundColor=[UIColor redColor];
[self.view addSubview:view];
UIRotationGestureRecognizer *rotation=[[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rote:)];
[view addGestureRecognizer:rotation]; [view release]; } -(void)rote:(UIRotationGestureRecognizer *)rotation{
CGFloat rt=rotation.rotation;
rotation.view.transform=CGAffineTransformRotate(rotation.view.transform, rt);
if(rotation.state==UIGestureRecognizerStateEnded){ }
rt=;
}
Tap手势
-(void)Rotaion{
UIView *view=[[UIView alloc] initWithFrame:CGRectMake(, , , )];
view.backgroundColor=[UIColor redColor];
[self.view addSubview:view];
UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)];
[view addGestureRecognizer:tap];
[tap release];
}
-(void)tap:(UITapGestureRecognizer *)tap{
tap.view.backgroundColor=[UIColor yellowColor];
}
原文地址:http://blog.csdn.net/totogo2010/article/details/8615940
ios 中手势用法的更多相关文章
- [BS-25] IOS中手势UIGestureRecognizer概述
IOS中手势UIGestureRecognizer概述 一.概述 iPhone中处理触摸屏的操作,在3.2之前是主要使用的是由UIResponder而来的如下4种方式: - (void)touches ...
- IOS中手势UIGestureRecognizer
通常在对视图进行缩放移动等操作的时候我们可以用UIScrollView,因为它里边自带了这些功能,我们要做的就是告诉UIScrollView的几个相关参数就可以了 但是没有实现旋转的手势即UIRota ...
- ios 中pickerView用法之国旗选择
QRViewController控制器 // // QRViewController.m // #import "QRViewController.h" #import " ...
- ios中MKHorizMenu用法
下载地址 https://github.com/MugunthKumar/MKHorizMenuDemo直接 加入MKHorizMenu目录即可 下载包地址 http://pan.baidu.com/ ...
- IOS各种手势操作实例
先看下效果 手势相关的介绍 IOS中手势操作一般是 UIGestureRecognizer 类的几个手势子类去实现,一般我们用到的手势就这么5种: 1.点击 UITapGestureRecogniz ...
- iOS中的触摸事件和手势处理
iOS中的事件可以分为三大类: 1> 触摸事件 2> 加速计事件 3> 远程控制事件 响应者对象 在iOS中不是任何对象都能处理事件,只有继承了UIResponder的对象才能接收并 ...
- iOS中block的用法 以及和函数用法的区别
ios中block的用法和函数的用法大致相同 但是block的用法的灵活性更高: 不带参数的block: void ^(MyBlock)() = ^{}; 调用的时候 MyBlock(); 带参数的 ...
- 【IOS】ios中NSUserDefault与android中的SharedPreference用法简单对比
以下内容为原创,欢迎转载,转载请注明 来自天天博客:http://www.cnblogs.com/tiantianbyconan/p/3405308.html 有Android开发经验的朋友对Shar ...
- 说说iOS中的手势及触摸
一.响应链 在IOS开发中会遇到各种操作事件,通过程序可以对这些事件做出响应. 首先,当发生事件响应时,必须知道由谁来响应事件.在IOS中,由响应者链来对事件进行响应,所有事件响应的类都是UIResp ...
随机推荐
- Round() 四舍五入 js银行家算法
首先问一下round(0.825,2) 返回的结果,大家猜一猜, 首先SQL server 返回的是 0.83 js的返回结果 是0.83,code 如下: var b = 0.825; ...
- [leetcode]Path Sum II @ Python
原题地址:https://oj.leetcode.com/problems/path-sum-ii/ 题意: Given a binary tree and a sum, find all root- ...
- GIST特征描述符使用
来源:http://www.cnblogs.com/justany/archive/2012/12/06/2804211.html 一种场景特征描述 场景特征描述? 通常的特征描述符都是对图片的局部特 ...
- mysql启动报错cannot allocate memory for the buffer pool处理
今天启动mysql服务器时失败了.去/var/log/mysql/查看error.log,报错信息如下: 160123 22:29:26 InnoDB: Initializing buffer poo ...
- a,b盘去哪儿?
我们知道,电脑的硬盘从c盘开始了,那我们不仅要问了,a,b盘符去哪儿了? 打开Windows系统的电脑,看到的第一个硬盘分区是C盘,请问A盘和B盘在哪里?所谓的硬盘分区号就是盘符,也就是驱动器号,是微 ...
- Swift语言从天而降,是否能掀起新一轮的科技革命?
Swift语言从天而降,是否能掀起新一轮的科技革命? Swift语言诞生到如今,才短短一个月多,Swift居然挤进TIOBE排行榜的第16位,相信这发展的速度绝不是不论什么一个语言可与之相提并论,那S ...
- 在Android上山寨了一个Ios9的LivePhotos,放Github上了
9月10号的凌晨上演了一场IT界的春晚,相信很多果粉(恩,如果你指坚果,那我也没办法了,是在下输了)都熬夜看了吧,看完打算去医院割肾了吧.在发布会上发布了游戏机 Apple TV,更大的砧板 Ipad ...
- 转 :scikit-learn的GBDT工具进行特征选取。
http://blog.csdn.net/w5310335/article/details/48972587 使用GBDT选取特征 2015-03-31 本文介绍如何使用scikit-learn的GB ...
- spark0.9分布式安装
http://blog.csdn.net/myboyliu2007/article/details/18990277 spark安装包:spark-0.9.0-incubating-bin-hadoo ...
- linux命令学习——md5sum
1.简介 MD5算法常常被用来验证网络文件传输的完整性,防止文件被人篡改.MD5 全称是报文摘要算法(Message-Digest Algorithm 5),此算法对任意长度的信息逐位进行计算,产生一 ...