我希望它是动画,所以我使用[UIView beginAnimations]
动画移动和图像的比例的UIButton
我试着用button.imageView.frame
动画(含图片设置为ImageView的),但它只是动画的位置,图像没有按根本不会缩小。
使用hateButton.frame
(当图像设置为backgroundImage时),backgroundImage会缩小但不是动画效果。
如何动画缩放UIButton图像?
我希望它是动画,所以我使用[UIView beginAnimations]
动画移动和图像的比例的UIButton
我试着用button.imageView.frame
动画(含图片设置为ImageView的),但它只是动画的位置,图像没有按根本不会缩小。
使用hateButton.frame
(当图像设置为backgroundImage时),backgroundImage会缩小但不是动画效果。
如何动画缩放UIButton图像?
我可以做到这一点使用Quartz 2D:
// move anchor point without moving frame
CGRect oldFrame = hateButton.frame;
hateButton.layer.anchorPoint = CGPointMake(0, 1); // bottom left
hateButton.frame = oldFrame;
[UIView beginAnimations:nil context:NULL];
CGAffineTransform newTransform;
newTransform = CGAffineTransformMakeScale(0.8, 0.8);
hateButton.transform = CGAffineTransformTranslate(newTransform, 0, -160);
[UIView commitAnimations];
确保导入Quartz2D太:
#import <QuartzCore/QuartzCore.h>
你可以调用和[UIView commintAnimations]
layoutIfNeeded
之间[UIView beginAnimations]
或[UIView animateWithDuration]
。
[UIView animateWithDuration:0.3f animations:^{
self.myButton.frame = aFrame;
[self.myButton layoutIfNeeded];
}];
请把代码一样... – 2010-04-12 07:09:07