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 ...
随机推荐
- c#中的数组、ArrayList、List区别【转】
首先说明C#中的Array类:Array 类是 C# 中所有数组的基类,它是在 System 命名空间中定义.Array 类提供了各种用于数组的属性和方法.关于Array类的一些属性及方法详见博文:C ...
- asp.net网站发布
1.iis里面新建一个网站,目录可以新建(例如:F:\dotNetWeb),还可以创建子文件夹如:F:\dotNetWeb\my,网站路径是可以自己设置的,也可以使用IIS默认的网站. 2.vs201 ...
- Android传感器应用——重力传感器实现滚动的弹球
一. 问题描述 Android中有多达11种传感器,不同的手机设备支持的传感器类型也不尽相同 1. 重力传感器 GV-sensor 2. 加速度传感器 G-sensor 3. 磁力传感器 M-se ...
- 移动端 h5开发相关内容总结——CSS篇
1.移动端开发视窗体的加入 h5端开发以下这段话是必须配置的 <meta name="viewport" content="width=device-width, ...
- Android -- 状态栏高度
干货 Class<?> c = null; Object obj = null; Field field = null; int x = 0, sbar = 0; try { c = Cl ...
- 【Spark】Spark-reduceByKey-深入理解
Spark-reduceByKey-深入理解 spark.apache.org_百度搜索 Apache Spark™ - Lightning-Fast Cluster Computing reduce ...
- 如何基于TensorFlow使用LSTM和CNN实现时序分类任务
https://www.jiqizhixin.com/articles/2017-09-12-5 By 蒋思源2017年9月12日 09:54 时序数据经常出现在很多领域中,如金融.信号处理.语音识别 ...
- 微信小程序--后台交互/wx.request({})方法/渲染页面方法 解析
小程序的后台获取数据方式get/post具体函数格式如下:wx.request({}) data: { logs:[] }, onLoad:function(){ this.getdata(); } ...
- DOM元素尺寸offsetWidth,scrollWidth,clientWidth等具体解释
样例: <div id="div" style="height: 200px;width: 200px;border:solid 50px red;overflow ...
- miniOrm
PetaPoco.Core https://www.nuget.org/packages/PetaPoco.Core/5.1.228