有没有可能以这种方式动画化一个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;}];