iphone - ui按钮动画

标签 iphone objective-c ios4 animation uibutton

是否有可能以这种方式为 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/

相关文章:

iphone - 如何从 Xcode 4 标记 Git 存储库

iphone - 将 UITouch 位置与 UIImageView 矩形进行比较

iphone - 丢失了我的 xcode 项目中的所有目标

objective-c - 使用新的文字语法将对象推到数组的末尾

ios - 在 iOS 中获取按钮的颜色

objective-c - 如何将 Facebook 粉丝页面集成到 iPhone 应用程序中?

iphone - 在iphone上将触摸屏坐标转换为3d Opengl世界坐标

objective-c - Audio Session 更改时 MPVolumeView slider 消失

iphone - 隐藏默认键盘

iphone - RestKit - 加载一个简单的数组