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 可以知道两个点之间的距离。

你可能感兴趣的:(iPhone开发)