防止CGAffineTransfromScale在self.view之外进行缩放

时间:2016-08-24 07:36:20

标签: ios objective-c xcode uipinchgesturerecognizer cgaffinetransformscale

我正在使用此方法来缩放imageView。

-(IBAction)handlePinching:(UIPinchGestureRecognizer *)recognizer {
  recognizer.view.transform = CGAffineTransformScale(recognizer.view.transform, recognizer.scale,recognizer.scale);
  recognizer.scale = 1;
}

如何防止我的imageView在self.view之外进行缩放?我不希望我的imageView的任何部分在self.view之外扩展。

1 个答案:

答案 0 :(得分:0)

在视图上将clipsToBounds设置为YES,以防止在视图范围之外绘制任何子视图:

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.view.clipsToBounds = YES;
}