uibutton动画
答
除非你想要一个更复杂的动画,你可以创建一个自定义类型的UIButton(通过改变类型的自定义或者与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;}];
因此,您希望麦穗是按钮,并且该领域是背景图像? – Ned 2011-03-16 19:02:44
是的,这是正确的:) – Leon 2011-03-16 19:37:26