IOS-UI-触控手势
来源:互联网 发布:mac airplay 小米盒子 编辑:程序博客网 时间:2024/06/03 23:50
#import"GCViewController.h"
//触控手势:
@interface GCViewController ()
@end
@implementation GCViewController
{
UIImageView *imageView;
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
[self initImageView];
}
- (void)initImageView{
imageView = [[UIImageView alloc] init];
imageView.frame = CGRectMake(100, 150, 100, 150);
imageView.image = [UIImage imageNamed:@"back2.jpg"];
[self.view addSubview:imageView];
imageView.userInteractionEnabled = YES;
[self creatPinges];
[self creatRota];
[self createPan];
[self creatLopngpress];
}
//*********************放大:**************//
- (void)creatPinges{
UIPinchGestureRecognizer *pinGes = [[UIPinchGestureRecognizer alloc] init];
[pinGes addTarget:self action:@selector(pinClick:)];
pinGes.delegate = self;
[imageView addGestureRecognizer:pinGes];
}
- (void)pinClick:(UIPinchGestureRecognizer *)pinGes{
//参数2,x方向的缩放比例
//参数3,y方向的缩放比例
pinGes.view.transform = CGAffineTransformScale(pinGes.view.transform,pinGes.scale, pinGes.scale);
//每次缩放的比例都设为,下次的缩放比例是基于上次的缩放结果。
pinGes.scale = 1;
}
//*********************移动:**************//
- (void)creatRota{
UIRotationGestureRecognizer *rotaGes = [[UIRotationGestureRecognizer alloc] init];
[rotaGes addTarget:self action:@selector(rotaClick:)];
rotaGes.delegate = self;
[imageView addGestureRecognizer:rotaGes];
}
- (void)rotaClick:(UIRotationGestureRecognizer *)rotaGes{
rotaGes.view.transform = CGAffineTransformRotate(rotaGes.view.transform, rotaGes.rotation);
rotaGes.rotation = 0;
}
//*********************旋转:**************//
- (void)createPan{
UIPanGestureRecognizer *panGes = [[UIPanGestureRecognizer alloc] init];
[panGes addTarget:self action:@selector(panCLick:)];
[imageView addGestureRecognizer:panGes];
}
- (void)panCLick:(UIPanGestureRecognizer *)pan{
CGPoint point = [pan translationInView:self.view];
pan.view.transform = CGAffineTransformTranslate(pan.view.transform, point.x, point.y);
[pan setTranslation:CGPointMake(0, 0) inView:self.view];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
//*********************长按:**************//
- (void)creatLopngpress{
UILongPressGestureRecognizer *longGes = [[UILongPressGestureRecognizer alloc] init];
[longGes addTarget:self action:@selector(longClick:)];
[imageView addGestureRecognizer:longGes];
}
- (void)longClick:(UILongPressGestureRecognizer *)longGes{
//按压达到0.5秒会触发操作,此次按压松开之后还会再次触发一次。
//设置触发时长:
longGes.minimumPressDuration = 1;//按压一秒之后会触发。
NSLog(@"123456");
}
//是否支持多个手势:
//这个方法的在用户操作时,判定为一种手势的同时还能判定为另一种手势。
//
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{
return YES;
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
- IOS-UI-触控手势
- IOS--UI--LessonGestureRecoginer 手势
- iOS开发 UI 触摸手势
- IOS(UI)_手势1
- iOS开发之UI手势
- IOS - UI - 手势触摸事件、手势识别、摇晃事件、耳机线控
- UI: UIGestureRecognizer IOS中手势的用法
- ios 手势UI控件事件冲突
- 手势 各大集锦 UI iOS
- [iOS UI进阶 - 5.0] 手势解锁Demo
- iOS UI里面五大手势使用
- iOS UI 03 事件和手势
- IOS(UI)_手势2(简单画板)
- ios开发笔记之手势触控
- ui手势
- ui手势
- UI手势
- UI 手势
- java结合mybatis批量快速插入数据
- 【引用】unity3d 嵌入iOS的 In App Purchase 应用程序内购买
- phpStorm 的严重问题,自动缓存导致SVN被还原
- Travel大神-记一次故障诊断:事物回滚
- Linux之Makefile(自动化变量)
- IOS-UI-触控手势
- Cognos审计模块(四)- 日志级别
- 疯狂的程序员——个人解读加经典语录
- 关于ActionBar 详解
- notification、widget整理
- 任意次方后的最后三位数
- 重新组织函数--Split Temporary Variable(分解临时变量)
- hdu 1408 盐水的故事
- JavaScript的一些知识碎片