问题描述
点击'record'BarButtonItem后,我想保持它以编程方式突出显示,直到录音结束。
after tapping the 'record' BarButtonItem I would like to keep it programmatically highlighted until the recording is over. The highlighting graphics of iOS are very good, therefor I would like to remain or set that state.
到目前为止,我发现'setSelected'和'setHighlighted',但这些都是不工作在UIBarButtonItem。
有关如何解决这个问题的任何建议?提前感谢Koen。
Up to now I found 'setSelected' and 'setHighlighted' but these do not work on a UIBarButtonItem.Any suggestions on how to solve this? Thank you in advance, Koen.
推荐答案
setSelected
和 setHighlighted
在UIControls工作,但不是UIBarButtonItems(这不是UIControls)。
setSelected
and setHighlighted
work fine on UIControls, but not UIBarButtonItems (which are not UIControls).
我建议使用UIBarButtonItem的(文档链接)方法将背景图片更改为模拟突出显示的内容。
I'd recommend using UIBarButtonItem's - (void)setBackgroundImage:(UIImage *)backgroundImage forState:(UIControlState)state barMetrics:(UIBarMetrics)barMetrics
(documentation linked) method to change the background image to something that mimics highlighting.
UIView的项目,也模仿突出显示(请参阅属性)。
You can also set a custom UIView on the item which also mimics highlighting (see the customView
property).
这篇关于以编程方式突出显示UIBarButtonItem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!