我有一个图像“image1”,它是一个 UIButton,我想要的是,如果我触摸这个按钮,图像的宽度乘以二(带动画)而不是高度只是宽度。 抱歉我的英语不好,我是法国人:/
最佳答案
这对于 block 动画来说相当容易。只需尝试一下:
imageView.contentMode = UIViewContentModeScaleAspectFit;
[UIView animateWithDuration:1.0
animations:^{
CGRect newRect = imageView.frame;
int movementToTheLeft = imageView.frame.size.width / 2;
newRect.size.width *= 2;
newRect.origin.x -= movementToTheLeft;
imageView.frame = newRect;
}
completion:^(BOOL finished){
[UIView animateWithDuration:1.0
animations:^{
NSLog(@"Scaled!");// Anything can go in this completion block, it should be used for any logic you need after the animation.
}
completion:^(BOOL finished){
;
}];
这应该会将 imageView 的宽度缩放 2。希望有帮助!
关于iphone - 使用动画修改 imageView 的宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7018729/