使 uibarbuttonitems 淡入淡出
我有一个完全用代码设置和控制的导航栏。所以它不会出现在IB中。我有一个按钮出现在“self.navigationitem.rightbarbutton = myButton;” 我通过将其设置为 NIL 来使其消失。我想知道如何让它淡入淡出?
I have a navigation bar that is set up and controlled completely with code. So it does not show up in IB. I have a button appear by "self.navigationitem.rightbarbutton = myButton;"
An I make it go away by setting it equal to NIL. What I am wondering is how could I make it fade in and out?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我找到了最适合我的方法
,然后
让它淡出。
I found what worked best for me
And then
To make it fade out.
Swift 版本
淡入:
navigationItem.setRightBarButtonItem(myButton,animated: true)
淡出:
navigationItem.setRightBarButtonItem(nil,animated:true)
Swift version
fade in:
navigationItem.setRightBarButtonItem(myButton, animated: true)
fade out:
navigationItem.setRightBarButtonItem(nil, animated: true)
不幸的是,没有内置的方法可以为导航栏中的栏按钮项目设置动画。 UIBarButtonItem 不是视图或控件,因此它不具有像 alpha 这样的可动画属性。
对于 UIToolbar 中的栏按钮项,有一种方法可以设置动画。有关详细信息,请参阅此答案:
是吗可以使用核心动画淡出 UIBarButtonItem 吗?
Unfortunately there is no built in way to animate this for bar button items in a navigation bar. UIBarButtonItem is not a view or a control so it does not have animatable properties like alpha.
For bar button items in a UIToolbar, there is a way to animate. See this answer for details:
Is it possible to use Core Animation to fade out a UIBarButtonItem?