是否有可能以这种方式为 uibutton 设置动画,使某个事物或任何东西从背景中出现,例如麦穗从地里长出来。
这可能吗?
谢谢:)
最佳答案
除非你想要一个更复杂的动画,你可以只创建一个自定义类型的 UIButton(通过将类型更改为 Custom 使用 IB,或者以编程方式使用 UIButton *aButton = [UIButton buttonWithType:UIButtonTypeCustom]
),然后使用 [aButton setImage:[UIImage imageNamed:@"wheat_ear"forState:UIControlStateNormal]
设置按钮的图像。
要移动它,只需正常设置其位置的动画...
[UIView animateWithDuration:0.5 animations:^{aButton.center = newCenter;}];
或者,为了提供它从现场出来的错觉,为图像的边界设置动画,使其以图像的宽度和零高度开始,以图像的宽度和高度结束:
CGRect originalFrame = aButton.frame;
aButton.frame = CGRectMake(originalFrame.origin.x, originalFrame.origin.y, originalFrame.size.width, 0);
[UIView animateWithDuration:0.5 animations:^{aButton.frame = originalFrame;}];
关于iphone - ui按钮动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5330282/