ios手势识别

使用手势识别

六种手势识别(继承于UIGestureRecongnizer基类):

UITapGestureRecongnizer--检测view上的单击操作

UIPinchGestureRecongnizer--检测view上两个手指的缩放操作

UIPanGestureRecongnizer--检测view的拖拽操作

UISwipeGestureRecongnizer--检测view的轻划操作

UIRotationGestureRecongnizer--检测view的旋转操作

UILongPressGestureRecongnizer-检测view上的长按操作

UITapGestureRecongnizer检测view上的单击操作

新建Empty Application项目,在xib中添加ImageView控件,Mode为Aspect Fit,选中User Interaction Enabled和Multiple Touch

HomeViewController.h

#import

@interface HomeViewController : UIViewController

@property (retain, nonatomic) IBOutlet UIImageView *imageView;

@end

HomeViewController.m

#import "HomeViewController.h"

@interface HomeViewController ()

@end

@implementation HomeViewController

@synthesize imageView;

- (void)viewDidLoad

{

UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGestureHandler:)];

tapGesture.numberOfTapsRequired = 2;

[imageView addGestureRecognizer:tapGesture];

[tapGesture release];

[super viewDidLoad];

}

- (IBAction)tapGestureHandler:(UIGestureRecognizer *)sender{

if (sender.view.contentMode == UIViewContentModeScaleAspectFit) {

sender.view.contentMode = UIViewContentModeScaleAspectFill;

} else {

sender.view.contentMode = UIViewContentModeScaleAspectFit;

}

}

- (void)dealloc {

[imageView release];

[super dealloc];

}

- (void)viewDidUnload {

[self setImageView:nil];

[super viewDidUnload];

}

@end

UIPinchGestureRecongnizer检测view上两个手指的缩放操作

HomeViewController.m

#import "HomeViewController.h"

@interface HomeViewController ()

@end

@implementation HomeViewController

@synthesize imageView;

CGFloat lastScaleValue = 1;

- (void)viewDidLoad

{

UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGestureHandler:)];

tapGesture.numberOfTapsRequired = 2;

[imageView addGestureRecognizer:tapGesture];

[tapGesture release];

UIPinchGestureRecognizer *pinchGesture = [[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(pinchGestureHandler:)];

[imageView addGestureRecognizer:pinchGesture];

[pinchGesture release];

[super viewDidLoad];

}

- (IBAction)tapGestureHandler:(UIGestureRecognizer *)sender{

if (sender.view.contentMode == UIViewContentModeScaleAspectFit) {

sender.view.contentMode = UIViewContentModeScaleAspectFill;

} else {

sender.view.contentMode = UIViewContentModeScaleAspectFit;

}

}

- (IBAction)pinchGestureHandler:(UIGestureRecognizer *)sender{

CGFloat scaleValue = [(UIPinchGestureRecognizer *)sender scale];

//如果手指做放大操作,scaleValue的值大于等于1;如果手指是缩小操作,scaleValue的值小于1

if (scaleValue > 1) {

sender.view.transform = CGAffineTransformMakeScale(lastScaleValue + (scaleValue-1), lastScaleValue + (scaleValue-1));

}else {

sender.view.transform = CGAffineTransformMakeScale(lastScaleValue * scaleValue, lastScaleValue * scaleValue);

}

//用户的手指离开了屏幕,将比例值记录在lastScaleValue 变量中

if (sender.state == UIGestureRecognizerStateEnded) {

if (scaleValue > 1) {

lastScaleValue += (scaleValue - 1);

}else {

lastScaleValue += scaleValue;

}

}

}

- (void)dealloc {

[imageView release];

[super dealloc];

}

- (void)viewDidUnload {

[self setImageView:nil];

[super viewDidUnload];

}

@end

UIRotationGestureRecongnizer检测view的旋转操作

#import "HomeViewController.h"

@interface HomeViewController ()

@end

@implementation HomeViewController

@synthesize imageView;

CGFloat lastScaleValue = 1;

CGFloat rotationValue;

- (void)viewDidLoad

{

UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGestureHandler:)];

tapGesture.numberOfTapsRequired = 2;

[imageView addGestureRecognizer:tapGesture];

[tapGesture release];

UIPinchGestureRecognizer *pinchGesture = [[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(pinchGestureHandler:)];

[imageView addGestureRecognizer:pinchGesture];

[pinchGesture release];

UIRotationGestureRecognizer *rotationGesture = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotationGestureHandler:)];

[imageView addGestureRecognizer:rotationGesture];

[rotationGesture release];

[super viewDidLoad];

}

- (IBAction)tapGestureHandler:(UIGestureRecognizer *)sender{

if (sender.view.contentMode == UIViewContentModeScaleAspectFit) {

sender.view.contentMode = UIViewContentModeScaleAspectFill;

} else {

sender.view.contentMode = UIViewContentModeScaleAspectFit;

}

}

- (IBAction)pinchGestureHandler:(UIGestureRecognizer *)sender{

CGFloat scaleValue = [(UIPinchGestureRecognizer *)sender scale];

if (scaleValue > 1) {

sender.view.transform = CGAffineTransformMakeScale(lastScaleValue + (scaleValue-1), lastScaleValue + (scaleValue-1));

}else {

sender.view.transform = CGAffineTransformMakeScale(lastScaleValue * scaleValue, lastScaleValue * scaleValue);

}

if (sender.state == UIGestureRecognizerStateEnded) {

if (scaleValue > 1) {

lastScaleValue += (scaleValue - 1);

}else {

lastScaleValue += scaleValue;

}

}

}

- (IBAction)rotationGestureHandler:(UIGestureRecognizer *)sender{

CGFloat rotation = [(UIRotationGestureRecognizer *)sender rotation];

CGAffineTransform transform = CGAffineTransformMakeRotation(rotation + rotationValue);

sender.view.transform = transform;

if (sender.state == UIGestureRecognizerStateEnded) {

rotationValue += rotation;

}

}

- (void)dealloc {

[imageView release];

[super dealloc];

}

- (void)viewDidUnload {

[self setImageView:nil];

[super viewDidUnload];

}

@end

UIPanGestureRecongnizer检测view的拖拽操作

#import "HomeViewController.h"

@interface HomeViewController ()

@end

@implementation HomeViewController

@synthesize imageView;

CGFloat lastScaleValue = 1;

CGFloat rotationValue;

CGPoint positionValue;

- (void)viewDidLoad

{

UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGestureHandler:)];

tapGesture.numberOfTapsRequired = 2;

[imageView addGestureRecognizer:tapGesture];

[tapGesture release];

UIPinchGestureRecognizer *pinchGesture = [[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(pinchGestureHandler:)];

[imageView addGestureRecognizer:pinchGesture];

[pinchGesture release];

UIRotationGestureRecognizer *rotationGesture = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotationGestureHandler:)];

[imageView addGestureRecognizer:rotationGesture];

[rotationGesture release];

UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureHandler:)];

[imageView addGestureRecognizer:panGesture];

[panGesture release];

[super viewDidLoad];

}

- (IBAction)tapGestureHandler:(UIGestureRecognizer *)sender{

if (sender.view.contentMode == UIViewContentModeScaleAspectFit) {

sender.view.contentMode = UIViewContentModeScaleAspectFill;

} else {

sender.view.contentMode = UIViewContentModeScaleAspectFit;

}

}

- (IBAction)pinchGestureHandler:(UIGestureRecognizer *)sender{

CGFloat scaleValue = [(UIPinchGestureRecognizer *)sender scale];

if (scaleValue > 1) {

sender.view.transform = CGAffineTransformMakeScale(lastScaleValue + (scaleValue-1), lastScaleValue + (scaleValue-1));

}else {

sender.view.transform = CGAffineTransformMakeScale(lastScaleValue * scaleValue, lastScaleValue * scaleValue);

}

if (sender.state == UIGestureRecognizerStateEnded) {

if (scaleValue > 1) {

lastScaleValue += (scaleValue - 1);

}else {

lastScaleValue += scaleValue;

}

}

}

- (IBAction)rotationGestureHandler:(UIGestureRecognizer *)sender{

CGFloat rotation = [(UIRotationGestureRecognizer *)sender rotation];

CGAffineTransform transform = CGAffineTransformMakeRotation(rotation + rotationValue);

sender.view.transform = transform;

if (sender.state == UIGestureRecognizerStateEnded) {

rotationValue += rotation;

}

}

- (IBAction)panGestureHandler:(UIGestureRecognizer *)sender{

CGPoint position = [(UIPanGestureRecognizer *)sender translationInView:imageView];

sender.view.transform = CGAffineTransformMakeTranslation(position.x + position.x,

position.y + position.y);

if (sender.state == UIGestureRecognizerStateEnded) {

positionValue.x += position.x;

positionValue.y += position.y;

}

}

- (void)dealloc {

[imageView release];

[super dealloc];

}

- (void)viewDidUnload {

[self setImageView:nil];

[super viewDidUnload];

}

@end

UISwipeGestureRecongnizer检测view的轻划操作

#import "HomeViewController.h"

@interface HomeViewController ()

@end

@implementation HomeViewController

@synthesize imageView;

CGFloat lastScaleValue = 1;

CGFloat rotationValue;

CGPoint positionValue;

NSArray *images;

int imageIndex = 0;

- (void)viewDidLoad

{

UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGestureHandler:)];

tapGesture.numberOfTapsRequired = 2;

[imageView addGestureRecognizer:tapGesture];

[tapGesture release];

UIPinchGestureRecognizer *pinchGesture = [[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(pinchGestureHandler:)];

[imageView addGestureRecognizer:pinchGesture];

[pinchGesture release];

UIRotationGestureRecognizer *rotationGesture = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotationGestureHandler:)];

[imageView addGestureRecognizer:rotationGesture];

[rotationGesture release];

/*注释panGesture的拖拽操作,否则划动和拖拽操作会产生混淆

UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureHandler:)];

[imageView addGestureRecognizer:panGesture];

[panGesture release];

*/

images = [[NSArray alloc] initWithObjects:@"iphone.png", @"mm.jpg", @"avatar.png", nil];

//默认情况下是向右的手势划动

UISwipeGestureRecognizer *swipeGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGestureHandler:)];

[imageView addGestureRecognizer:swipeGesture];

[swipeGesture release];

//定义向左的手势划动

UISwipeGestureRecognizer *swipeLeftGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGestureHandler:)];

swipeLeftGesture.direction = UISwipeGestureRecognizerDirectionLeft;

[imageView addGestureRecognizer:swipeLeftGesture];

[swipeLeftGesture release];

[super viewDidLoad];

}

- (IBAction)tapGestureHandler:(UIGestureRecognizer *)sender{

if (sender.view.contentMode == UIViewContentModeScaleAspectFit) {

sender.view.contentMode = UIViewContentModeScaleAspectFill;

} else {

sender.view.contentMode = UIViewContentModeScaleAspectFit;

}

}

- (IBAction)pinchGestureHandler:(UIGestureRecognizer *)sender{

CGFloat scaleValue = [(UIPinchGestureRecognizer *)sender scale];

if (scaleValue > 1) {

sender.view.transform = CGAffineTransformMakeScale(lastScaleValue + (scaleValue-1), lastScaleValue + (scaleValue-1));

}else {

sender.view.transform = CGAffineTransformMakeScale(lastScaleValue * scaleValue, lastScaleValue * scaleValue);

}

if (sender.state == UIGestureRecognizerStateEnded) {

if (scaleValue > 1) {

lastScaleValue += (scaleValue - 1);

}else {

lastScaleValue += scaleValue;

}

}

}

- (IBAction)rotationGestureHandler:(UIGestureRecognizer *)sender{

CGFloat rotation = [(UIRotationGestureRecognizer *)sender rotation];

CGAffineTransform transform = CGAffineTransformMakeRotation(rotation + rotationValue);

sender.view.transform = transform;

if (sender.state == UIGestureRecognizerStateEnded) {

rotationValue += rotation;

}

}

- (IBAction)panGestureHandler:(UIGestureRecognizer *)sender{

CGPoint position = [(UIPanGestureRecognizer *)sender translationInView:imageView];

sender.view.transform = CGAffineTransformMakeTranslation(position.x + position.x,

position.y + position.y);

if (sender.state == UIGestureRecognizerStateEnded) {

positionValue.x += position.x;

positionValue.y += position.y;

}

}

- (IBAction)swipeGestureHandler:(UIGestureRecognizer *)sender{

UISwipeGestureRecognizerDirection direction =[(UISwipeGestureRecognizer *)sender direction];

switch (direction) {

case UISwipeGestureRecognizerDirectionUp:

NSLog(@"向上划动");

break;

case UISwipeGestureRecognizerDirectionDown:

NSLog(@"向下划动");

break;

case UISwipeGestureRecognizerDirectionLeft:

imageIndex++;

break;

case UISwipeGestureRecognizerDirectionRight:

imageIndex--;

break;

default:

break;

}

imageIndex = (imageIndex < 0) ? ([images count] - 1):imageIndex % [images count];

imageView.image = [UIImage imageNamed:[images objectAtIndex:imageIndex]];

}

- (void)dealloc {

[images release];

[imageView release];

[super dealloc];

}

- (void)viewDidUnload {

[self setImageView:nil];

[super viewDidUnload];

}

@end

UILongPressGestureRecongnizer检测view上的长按操作

添加UIActionSheetDelegate协议

HomeViewController.h

#import

@interface HomeViewController : UIViewController

{}

@property (retain, nonatomic) IBOutlet UIImageView *imageView;

@end

HomeViewController.m

#import "HomeViewController.h"

@interface HomeViewController ()

@end

@implementation HomeViewController

@synthesize imageView;

CGFloat lastScaleValue = 1;

CGFloat rotationValue;

CGPoint positionValue;

NSArray *images;

int imageIndex = 0;

- (void)viewDidLoad

{

UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGestureHandler:)];

tapGesture.numberOfTapsRequired = 2;

[imageView addGestureRecognizer:tapGesture];

[tapGesture release];

UIPinchGestureRecognizer *pinchGesture = [[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(pinchGestureHandler:)];

[imageView addGestureRecognizer:pinchGesture];

[pinchGesture release];

UIRotationGestureRecognizer *rotationGesture = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotationGestureHandler:)];

[imageView addGestureRecognizer:rotationGesture];

[rotationGesture release];

/*注释panGesture的拖拽操作,否则划动和拖拽操作会产生混淆

UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureHandler:)];

[imageView addGestureRecognizer:panGesture];

[panGesture release];

*/

images = [[NSArray alloc] initWithObjects:@"iphone.png", @"mm.jpg", @"avatar.png", nil];

//默认情况下是向右的手势划动

UISwipeGestureRecognizer *swipeGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGestureHandler:)];

[imageView addGestureRecognizer:swipeGesture];

[swipeGesture release];

//定义向左的手势划动

UISwipeGestureRecognizer *swipeLeftGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGestureHandler:)];

swipeLeftGesture.direction = UISwipeGestureRecognizerDirectionLeft;

[imageView addGestureRecognizer:swipeLeftGesture];

[swipeLeftGesture release];

//开始长按的内容部分

UILongPressGestureRecognizer *longpressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longpressGestureHandler:)];

longpressGesture.minimumPressDuration = 1;

longpressGesture.allowableMovement = 15;

longpressGesture.numberOfTouchesRequired = 1;

[imageView addGestureRecognizer:longpressGesture];

[longpressGesture release];

[super viewDidLoad];

}

- (IBAction)tapGestureHandler:(UIGestureRecognizer *)sender{

if (sender.view.contentMode == UIViewContentModeScaleAspectFit) {

sender.view.contentMode = UIViewContentModeScaleAspectFill;

} else {

sender.view.contentMode = UIViewContentModeScaleAspectFit;

}

}

- (IBAction)pinchGestureHandler:(UIGestureRecognizer *)sender{

CGFloat scaleValue = [(UIPinchGestureRecognizer *)sender scale];

if (scaleValue > 1) {

sender.view.transform = CGAffineTransformMakeScale(lastScaleValue + (scaleValue-1), lastScaleValue + (scaleValue-1));

}else {

sender.view.transform = CGAffineTransformMakeScale(lastScaleValue * scaleValue, lastScaleValue * scaleValue);

}

if (sender.state == UIGestureRecognizerStateEnded) {

if (scaleValue > 1) {

lastScaleValue += (scaleValue - 1);

}else {

lastScaleValue += scaleValue;

}

}

}

- (IBAction)rotationGestureHandler:(UIGestureRecognizer *)sender{

CGFloat rotation = [(UIRotationGestureRecognizer *)sender rotation];

CGAffineTransform transform = CGAffineTransformMakeRotation(rotation + rotationValue);

sender.view.transform = transform;

if (sender.state == UIGestureRecognizerStateEnded) {

rotationValue += rotation;

}

}

- (IBAction)panGestureHandler:(UIGestureRecognizer *)sender{

CGPoint position = [(UIPanGestureRecognizer *)sender translationInView:imageView];

sender.view.transform = CGAffineTransformMakeTranslation(position.x + position.x,

position.y + position.y);

if (sender.state == UIGestureRecognizerStateEnded) {

positionValue.x += position.x;

positionValue.y += position.y;

}

}

- (IBAction)swipeGestureHandler:(UIGestureRecognizer *)sender{

UISwipeGestureRecognizerDirection direction =[(UISwipeGestureRecognizer *)sender direction];

switch (direction) {

case UISwipeGestureRecognizerDirectionUp:

NSLog(@"向上划动");

break;

case UISwipeGestureRecognizerDirectionDown:

NSLog(@"向下划动");

break;

case UISwipeGestureRecognizerDirectionLeft:

imageIndex++;

break;

case UISwipeGestureRecognizerDirectionRight:

imageIndex--;

break;

default:

break;

}

imageIndex = (imageIndex < 0) ? ([images count] - 1):imageIndex % [images count];

imageView.image = [UIImage imageNamed:[images objectAtIndex:imageIndex]];

}

- (IBAction)longpressGestureHandler:(UIGestureRecognizer *)sender{

if ([(UILongPressGestureRecognizer *)sender state] == UIGestureRecognizerStateBegan) {

UIActionSheet *actionSheet = [[UIActionSheet alloc]

initWithTitle:@"图片操作"

delegate:self

cancelButtonTitle:nil

destructiveButtonTitle:nil

otherButtonTitles:@"保存", @"复制", nil];

[actionSheet showInView:self.view];

[actionSheet release];

}

}

- (void)dealloc {

[images release];

[imageView release];

[super dealloc];

}

- (void)viewDidUnload {

[self setImageView:nil];

[super viewDidUnload];

}

@end

多点触摸识别

有些时候,我们只想简单地去识别用户在屏幕上的操作,而不是只针对某个特定的view,我们可以通过以下四个方法进行屏幕的触摸的识别。

touchesBegan:withEvent:当有一个或多个手指触摸屏幕时被触发。

touchesMoved:withEvent:当有一个或多个手指在屏幕上移动时被触发。

touchesEnded:withEvent:当有一个或多个手指离开屏幕时被触发。

touchesCancelled:withEvent: 当系统事件(内存溢出警告或者来电)发生时,取消触摸操作。

检测单点触摸

HomeViewController.h code:

#import

@interface HomeViewController : UIViewController

@property (retain, nonatomic) IBOutlet UIImageView *imageView;

@end

HomeViewController.m code:

#import "HomeViewController.h"

@interface HomeViewController ()

@end

@implementation HomeViewController

@synthesize imageView;

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

NSSet *allTouches = [event allTouches];

switch ([allTouches count]) {

case 1:

{

UITouch *touch = [[allTouches allObjects] objectAtIndex:0];

if ([touch tapCount] == 1 ) {

imageView.contentMode = UIViewContentModeScaleAspectFit;

}else if ([touch tapCount] == 2) {

imageView.contentMode = UIViewContentModeScaleAspectFill;

}

}

break;

default:

break;

}

}

- (void)viewDidLoad

{

[super viewDidLoad];

}

- (void)dealloc {

[imageView release];

[super dealloc];

}

@end

检测多点触摸

HomeViewController.h code:

#import

@interface HomeViewController : UIViewController

@property (retain, nonatomic) IBOutlet UIImageView *imageView;

- (CGFloat)distance:(CGPoint)fromPoint toPoint:(CGPoint)toPoint;

@end

HomeViewController.m code:

#import "HomeViewController.h"

@interface HomeViewController ()

@end

@implementation HomeViewController

@synthesize imageView;

CGFloat originalDistance;

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

NSSet *allTouches = [event allTouches];

switch ([allTouches count]) {

case 1:{

UITouch *touch = [[allTouches allObjects] objectAtIndex:0];

if ([touch tapCount] == 1 ) {

imageView.contentMode = UIViewContentModeScaleAspectFit;

}else if ([touch tapCount] == 2) {

imageView.contentMode = UIViewContentModeScaleAspectFill;

}

}

break;

case 2:{

UITouch *touch1 = [[allTouches allObjects] objectAtIndex:0];

UITouch *touch2 = [[allTouches allObjects] objectAtIndex:1];

CGPoint touch1PT = [touch1 locationInView:[self view]];

CGPoint touch2PT = [touch2 locationInView:[self view]];

NSLog(@"Touch1:%.0f, %.0f", touch1PT.x, touch1PT.y);

NSLog(@"Touch2:%.0f, %.0f", touch2PT.x, touch2PT.y);

originalDistance = [self distance:touch1PT toPoint:touch2PT];

}break;

default:

break;

}

}

- (CGFloat)distance:(CGPoint)fromPoint toPoint:(CGPoint)toPoint{

float lengthX = fromPoint.x - toPoint.x;

float lengthY = fromPoint.y - toPoint.y;

return sqrt((lengthX * lengthX) + (lengthY * lengthY));

}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{

NSSet *allTouches = [event allTouches];

switch ([allTouches count]) {

case 1:

break;

case 2:{

UITouch *touch1 = [[allTouches allObjects] objectAtIndex:0];

UITouch *touch2 = [[allTouches allObjects] objectAtIndex:1];

CGPoint touch1PT = [touch1 locationInView:[self view]];

CGPoint touch2PT = [touch2 locationInView:[self view]];

NSLog(@"Touch1:%.0f, %.0f", touch1PT.x, touch1PT.y);

NSLog(@"Touch2:%.0f, %.0f", touch2PT.x, touch2PT.y);

CGFloat currentDistance = [self distance:touch1PT toPoint:touch2PT];

if (currentDistance > originalDistance) {

imageView.frame = CGRectMake(imageView.frame.origin.x-2,imageView.frame.origin.y-2,

imageView.frame.size.width+4, imageView.frame.size.height+4);

}else {

imageView.frame = CGRectMake(imageView.frame.origin.x+2, imageView.frame.origin.y+2,

imageView.frame.size.width-4, imageView.frame.size.height-4);

}

originalDistance = currentDistance;

}break;

default:

break;

}

}

- (void)viewDidLoad

{

[super viewDidLoad];

}

- (void)dealloc {

[imageView release];

[super dealloc];

}

@end

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 206,126评论 6 481
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 88,254评论 2 382
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 152,445评论 0 341
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 55,185评论 1 278
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 64,178评论 5 371
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,970评论 1 284
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,276评论 3 399
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,927评论 0 259
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 43,400评论 1 300
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,883评论 2 323
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,997评论 1 333
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,646评论 4 322
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,213评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,204评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,423评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,423评论 2 352
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,722评论 2 345

推荐阅读更多精彩内容