iphone开发中的手势操作:Pinches 捏合

Automatic Gesture Recognition实现十分简单

- (void)viewDidLoad
{
[super viewDidLoad];
UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc]
initWithTarget:self action:@selector(doPinch:)];
[self.view addGestureRecognizer:pinch];
}

 

- (void)doPinch:(UIPinchGestureRecognizer *)pinch {
if (pinch.state == UIGestureRecognizerStateBegan) {
initialFontSize = label.font.pointSize;
} else {
label.font = [label.font fontWithSize:initialFontSize * pinch.scale];
}
}

@property (assign, nonatomic) CGFloat initialFontSize;


也可以自己实现,使用distanceBetweenPoints 可以知道两个点之间的距离。

posted on 2012-03-26 11:13  老Zhan  阅读(503)  评论(2编辑  收藏  举报