在视图中淡入淡出UIButton
在我的iPad应用程序中,我需要显示封面 – 出版物的图像。 用户可以点击一个封面获得详细信息。
我考虑将UIButtons作为自定义button,并将封面图像作为背景图像进行渲染。 是否可以淡入淡出UIButtons? 用户可以select要显示的出版物类别,并且他改变了我想要淡出某些出版物的类别。
任何UIView
(包括UIButton
)的alpha
属性都可以使用基于块的animation方法来animation:
[UIView animateWithDuration:0.25 animations:^{myButton.alpha = 0.0;}];
这将在0.25秒内淡出button。 将alpha
设置为1.0将使其淡入。
如果您希望button在animation制作时响应事件,请确保启用用户交互
[UIView animateWithDuration:5.0 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction animations:^{ button.alpha = 0.0; } completion:nil];