ScrollView方法
- (void)viewDidLoad
{
[super viewDidLoad];
self.imageView=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"Cool.jpg"]];
NSLog(@"%@",NSStringFromCGRect(self.view.frame));
self.scrollView.frame=self.view.frame;
self.imageView.frame=self.scrollView.frame;
NSLog(@"%@",NSStringFromCGRect(self.imageView.frame));
[self.imageView setContentMode:UIViewContentModeScaleAspectFit];
self.scrollView.delegate=self;
[self.scrollView setMaximumZoomScale:5.0];
[self.scrollView setMinimumZoomScale:1.0];
[self.scrollView addSubview:self.imageView];
// self.scrollView.contentSize=CGSizeMake(320, 1000);
// Do any additional setup after loading the view, typically from a nib.
}
#pragma mark - UIScrollViewDelegate
-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{
return self.imageView;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
Gesture方法
//
// PLGestureZoomDemoVC.m
// ZoomScrollView
//
// Created by liu poolo on 14-4-2.
// Copyright (c) 2014年 liu poolo. All rights reserved.
//
#import “PLGestureZoomDemoVC.h”;
@interface PLGestureZoomDemoVC (){
UIPinchGestureRecognizer *_gst;
float _lastScale;
CGSize beginImageViewSize;
}
@end
@implementation PLGestureZoomDemoVC
- (void)viewDidLoad
{
[super viewDidLoad];
self.image=[UIImage imageNamed:@"Cool.jpg"];
self.imageView=[[UIImageView alloc]initWithImage:self.image];
self.imageView.center=self.view.center;
[self.view addSubview:self.imageView];
_gst=[[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinchGestureResponse:)];
[self.imageView addGestureRecognizer:_gst];
UITapGestureRecognizer *tapGtr=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGestureResponse:)];
tapGtr.numberOfTapsRequired=2;
[self.imageView addGestureRecognizer:tapGtr];
self.imageView.userInteractionEnabled=YES;
beginImageViewSize=self.imageView.frame.size;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
-(void)pinchGestureResponse:(UIPinchGestureRecognizer *) pinGst{
if(pinGst.state==UIGestureRecognizerStateBegan){
_lastScale=pinGst.scale;
}
float scale=pinGst.scale/_lastScale;
_lastScale=pinGst.scale;
[pinGst.view setTransform:CGAffineTransformScale(pinGst.view.transform, scale, scale)];
NSLog(@"%f",scale);
}
-(void)tapGestureResponse:(UITapGestureRecognizer *) tapGst{
[tapGst.view setTransform:CGAffineTransformScale(tapGst.view.transform, beginImageViewSize.width/tapGst.view
.frame.size.width, beginImageViewSize.height/tapGst.view
.frame.size.height)];
}
@end
分享到:
相关推荐
Qt实现多点触控与手势识别
后来 发现 IOS5 之后 scrollview 自带了 pan手势 (英语差 不会打gesture) 多试了几次 发现 直接移动 scrollview 低层的 view 就不会出现 视差了 但是 偶尔会抖动 用了个 遮盖的方法 具体 看代码吧!
本文将会利用上篇教程【如何在iPhone上绘制出一个笑脸】,在原有的基础上加入【手势】进行放大缩小的功能。
本文描绘了惠普Touchpad Gesture触摸板多点触控技术的概念,并详解了其设置及基本应用,同时就常见的一些疑问进行了解答。
华硕smartgesture触控板驱动是一款专为华硕笔记本打造的官方驱动程序设置工具,它可进行多项参数设置,使手指滑动更加流畅,操作体验更舒适,电脑使用更便捷,需要的朋友快下载体验吧!软件介绍智慧型触控板可识别...
iOS 10 App Development Essentials: Learn to Develop iOS 10 Apps with Xcode 8 and Swift 3 Author: Neil Smyth Length: 816 pages Edition: 1 Language: English Publisher: CreateSpace Independent Publishing...
GESTURE
手势 拖拽 Demo IOS Gesture 代码实例
华硕触控板控制器 ASUS Smart Gesture
用win7提供的API实现OSG多点触控漫游的研发总结 很难得的win7多点触控参考资料 包括WM_TOUCH的处理及WM_GESTURE的处理 包含了触摸屏选型对比 包含各种尝试方法及尝试结果
RxSwift 实现的 View Gesture 库.zip,视图手势的rxswift反应式包装器
ios源码之整合cocos2d手势识别-GestureRecognizers.rar
Identifying Gestures using iOS 8 Gesture Recognizers Chapter 52. An iOS 8 Gesture Recognition Tutorial Chapter 53. Implementing TouchID Authentication in iOS 8 Apps Chapter 54. An Overview of iOS 8 ...
Creating direct touch-based interfaces with multi-touch, gestures, and custom gesture recognizers Building and customizing controls in powerful ways Adding novel motion effects Alerting users via pop-...
高级手势实现LeftMenu: 使用方法很简单: self.menuView = [[LeftMenuView ShareManager] initWithContainerViewController:self]; self.menuView.menuViewDelegate = self; [self....
IOS应用源码——xemus-cocos2d-GestureRecognizers-c87d379.rar
smooth gesture for chrome. chrome的插件
iOS游戏应用源代码——xemus-cocos2d-GestureRecognizers-c87d379.zip
代码详细使用了7中手势,方便大家使用时CV