试图放大/缩小 imageView。
我已经成功地做到了,所以现在我试图在视图上放置一些按钮,并在点击按钮时放大该区域。
我该如何实施?
到目前为止,这是我的代码
-(void)zoomHere:(UIButton *)sender{
NSLog(@"zoom in");
//[self performSelector:@selector()
// withObject:nil
// afterDelay:1.6f];
CGAffineTransform transformer = CGAffineTransformScale(imageView.transform, 1.05, 1.05);
if (transformer.a < 5) {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration: 0.2];
imageView.transform = transformer;
[UIView setAnimationDelegate:self];
[UIView commitAnimations];
}
}
并且视图确实加载了
- (void)viewDidLoad
{
[super viewDidLoad];
UIView *buttonView = [[UIView alloc]initWithFrame:CGRectMake(00.0, 20.0, 768, 1004.0)];
zoomHere = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[zoomHere addTarget:self
action:@selector(zoomHere:)
forControlEvents:UIControlEventTouchDown];
[zoomHere setTitle:@"ZoomIN" forState:UIControlStateNormal];
zoomHere.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
[buttonView addSubview:zoomHere];
buttonView.multipleTouchEnabled = YES;
[self.view addSubview:buttonView];
}
它仍然会放大,但不会放大按钮所在的屏幕区域!