我正在使用以下内容来缩放图像,但是它从左上角开始缩放,如何从中心缩放
[UIView animateWithDuration:duration delay:delay options:options
animations:^{
myImageView.frame = frame;
myImageView.alpha = alpha;
}
completion:^(BOOL finished) {
}
];
答案 0 :(得分:35)
[UIView animateWithDuration:0.5
delay:0
options:UIViewAnimationOptionBeginFromCurrentState
animations:(void (^)(void)) ^{
myImageView.transform=CGAffineTransformMakeScale(1.2, 1.2);
}
completion:^(BOOL finished){
myImageView.transform=CGAffineTransformIdentity;
}];
这将完美地工作 祝你好运
答案 1 :(得分:3)
试试这个:
[UIView animateWithDuration:2
animations:^{
float zoomScal = 5; //want 5x zoom
CGPoint CenterPoint = CGPointMake(200, 300); // want center point to this
imgArtifactImage.frame = CGRectMake(- CenterPoint.x * (zoomScal-1),- CenterPoint.y * (zoomScal-1),self.view.frame.size.width * zoomScal,self.view.frame.size.height * zoomScal);
} completion:^(BOOL finished){}];
这对我有用。
答案 2 :(得分:2)
这可以是放大图像的动画块
此处为View U可以使用uiimageview
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:GROW_ANIMATION_DURATION_SECONDS];
theView.transform = CGAffineTransformMakeScale(1.2, 1.2);
[UIView commitAnimations];