如何在 UIBarButtonItem 上触发高亮效果
当您点击 UIToolbar
中的 UIBarButtonItem
时,会出现白色发光效果。
是否可以触发事件来显示此效果?
我不想按下按钮。只应显示效果。我想向用户展示该按钮后面有新内容。
感谢您的帮助!
When you tap on a UIBarButtonItem
in a UIToolbar
, there is a white glow effect.
Is there a possibility to fire an event to show this effect?
I don't want to press the button. Only the effect should be displayed. I want to visualize to the user, that there is new content behind this button.
Thanks for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
这是“highlight.png”,我不是在开玩笑! (尽管您可能在白色背景上看不到它。)
Heres the "highlight.png", I'm not kidding! (Though you may not seeing it on a white background.)
以下方法假设您正在使用导航控制器的toolbarItems 属性,并且您要突出显示的按钮是该数组中的最后一项。当然,您可以将其应用到任何工具栏,并根据需要选择不同的数组索引。
现在这并不完全完美,因为动画将新按钮从屏幕左下角移动。不过,我认为可以通过一点努力将其关闭。
请注意,我使用了 PeakJi 的图像。
我希望这对你有用。
享受吧,
达米安
The following method assumes you are using the toolbarItems property of a navigation controller and that the button you want to highlight is the last item in that array. You can apply it to any toolbar, of course, and pick a different array index if necessary.
Right now this is not exactly perfect, because the animation moves the new button from the lower left of the screen. However, I think that can be turned off with a little effort.
Note that I used PeakJi's image.
I hope this works for you.
Enjoy,
Damien
对于栏项目
一般来说 - 假设您有一个按钮
,您可以在任何给定点以编程方式调用此函数:
或者如果您喜欢突出显示图像
一个非常简单的替代方案:
也就是说,您也可以像这样设置按钮:
For Bar items
In General - Assuming you have a button
you can at any given point, programmatically call this function:
or if you like to have an highlight image
A very simple alternative:
That said , you can also set the button like this:
您可以尝试重新创建具有不同样式的新栏按钮项目,然后将其重新分配回来。我的实验是:
在 viewDidLoad:
和方法突出显示中:
您的实现可能与我的不同,但只要您可以重新分配栏按钮,我认为它会按预期工作。祝你好运 :)
You can try to recreate a new bar button item with different style, and then reassign it back. My experiment was:
In viewDidLoad:
And in method highlight:
Your implementation might be different than mine, but as long as you are fine with reassigning the bar button, I think it'll work as expected. Good luck :)
如果您有一个类别:
那么您需要这样的代码……
2 秒后突出显示导航栏中的按钮。
If you have a category:
Then you need code like this…
…to highlight the button in the navigation bar after 2 seconds.
一个简单的方法是使用 CustomView (UIBUtton) 初始化 UIBarButtonItem
A simple ay is to init your UIBarButtonItem with a CustomView (UIBUtton)