如何使用Swift以编程方式将导航栏按钮设置为特定图像??
答案 0 :(得分:1)
let rightButton: UIButton = UIButton.buttonWithType(UIButtonType.Custom)
rightButton.frame = CGRectMake(0, 0, 40, 40) ;
rightButton.setImage(UIImage(named:"ImageName.png"), forState: UIControlState.Normal)
rightButton.addTarget(self, action: "rightNavButtonClick:", forControlEvents: UIControlEvents.TouchUpInside)
var rightBarButtonItem: UIBarButtonItem = UIBarButtonItem(customView: rightButton)
self.navigationItem.setLeftBarButtonItem(rightBarButtonItem, animated: false);
试试这个应该可行!!