[英]UIButton change size with center
I am animating the change in width and height of a UIButton in this way: 我正在以这种方式对UIButton的宽度和高度的变化进行动画处理:
[UIView animateWithDuration:0.5
delay:0.0
options: UIViewAnimationCurveEaseInOut
animations:^{
CGRect frame = [[sender view] frame];
frame.size.width = 0;
frame.size.height = 0;
[[sender view] setFrame:frame];
}
completion:^(BOOL finished){
}];
The button is changing size just fine, but I would like it to close down on its centre, not on its corner. 该按钮可以很好地更改大小,但是我希望它关闭在其中心而不是在角落。 I know this is because it closes on the x and y coords, but can I make it close it down to the centre?
我知道这是因为它在x和y坐标上闭合,但是我可以使其在中心向下闭合吗?
这是您在动画块中想要的:
[sender view].frame = (CGRect){[[sender view] center],CGSizeZero};
How about: 怎么样:
[UIView animateWithDuration:0.5
delay:0.0
options: UIViewAnimationCurveEaseInOut
animations:^{
CGRect frame = [[sender view] frame];
frame.origin.x += frame.size.width / 2.0f;
frame.origin.y += frame.size.height / 2.0f;
frame.size.width = 0;
frame.size.height = 0;
[[sender view] setFrame:frame];
}
completion:^(BOOL finished){
}];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.