我想将代码从“播放”更改为“暂停”的UIBarButtonItem的标识符.我怎样才能做到这一点?
谢谢
解决方法
1)初始化一个新按钮
//change to play let button = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Play,target: self,action: "someAction") navigationBar.topItem.leftBarButtonItem = button //change to pause let button = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Pause,action: "someOtherAction") navigationBar.topItem.leftBarButtonItem = button
2)只需更改文字:
navigationBar.topItem?.leftBarButtonItem?.title = "AnyText"
如果您在访问导航栏时遇到问题,最好只设置一些标签(我喜欢使用特定视图的负标签*来确保2个视图*不会获得相同的标签).
然后你可以这样做:
let navigationBar = (self.view.viewWithTag(-1) as UINavigationBar) navigationBar.topItem?.leftBarButtonItem?.title = "AnyText"