[英]make a UIButton imageView Bigger than the frame and then back to its original size?
我想让UIButton
图像从当前大小转换为其大小的两倍,然后回到原始大小,类似于facebook“like”动画。
我正在使用此代码但由于某种原因它正在执行相反的操作; 即先缩小,然后再变大。
我究竟做错了什么? 它在uiimageView
上运行完美,但在uibutton
上uiimageView
不uibutton
[self.likeButton setClipsToBounds:NO];
CGAffineTransform firstTransform = self.likeButton.imageView.transform;
[UIView animateWithDuration:.15f animations:^{
self.likeButton.imageView.transform = CGAffineTransformScale(firstTransform, 2, 2);
} completion:^(BOOL finished) {
[UIView animateWithDuration:.15f animations:^{
self.likeButton.imageView.transform = firstTransform;
}];
}];
图层具有属性masksToBounds
和UIView具有clipsToBounds
。 很可能按钮在主视图或子视图上将这些设置为YES。 您可以发现哪些设置为YES,并将它们暂时设置为NO。
如果有人有兴趣我通过在按钮上方添加uiimageview并对其进行动画处理而不是按钮图像来解决它。
它是一个黑客但它的工作。
//设置button.masktobound = NO
[UIView animateWithDuration:.15f animations:^{
self.likeButton.imageView.transform = CGAffineTransformMakeScale(2.0,2.0);
} completion:^(BOOL finished) {
[UIView animateWithDuration:.15f animations:^{
self.likeButton.imageView.transform = CGAffineTransformMakeScale(1.0,1.0);
}];
}];
//尝试这个
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.