Ios 如何使UIBarButton在禁用时不变灰?

Ios 如何使UIBarButton在禁用时不变灰?,ios,swift,customization,uibarbuttonitem,Ios,Swift,Customization,Uibarbuttonitem,我有一个UIBarButton saveBarButton将屏幕的图像保存到摄像机滚轮上。当用户按下saveBarButton时,图像被保存,并且UIBarButton saveBarButton更改为UIImage doneIcon1.2秒,以向用户指示图像已保存。当saveBarButton显示doneIcon时,我禁用saveBarButton。但是,当我这样做时,saveBarButton将变灰 我的问题是:当禁用时,如何阻止UIBarButton变灰 我的代码: //create UI

我有一个
UIBarButton saveBarButton
将屏幕的图像保存到摄像机滚轮上。当用户按下
saveBarButton
时,图像被保存,并且
UIBarButton saveBarButton
更改为
UIImage doneIcon
1.2秒,以向用户指示图像已保存。当
saveBarButton
显示
doneIcon
时,我禁用
saveBarButton
。但是,当我这样做时,
saveBarButton
将变灰

我的问题是:当禁用时,如何阻止
UIBarButton
变灰

我的代码:

//create UIBarButton saveBarButton
override func viewDidLoad() {    
    let saveBarButton = UIBarButtonItem(image: UIImage(named: "saveIcon"), style: .Plain, target: self, action: "save:")
    saveBarButton.tintColor = colorGreyDark
}

//save function called when press saveBarButton
func save(sender: UIBarButtonItem) {
    //save image
    deselectShape()
    let window: UIWindow! = UIApplication.sharedApplication().keyWindow
    let windowImage = capture(window)
    UIImageWriteToSavedPhotosAlbum(windowImage
        , nil, nil, nil)

    //Change saveBarButton to indicate to user that image was saved 
    sender.image = UIImage(named: "doneIcon")
    sender.enabled = false //disable saveBarButton
    self.performSelector("canSaveAgain:", withObject: sender, afterDelay: 1.2)
}

//Change saveBarButton to original icon to indicate to user that can save another image
func canSaveAgain(sender: UIBarButtonItem){
    sender.image = UIImage(named: "saveIcon")
    sender.enabled = true //enable saveBarButton
}

其中一种方法是使用
customView
创建
UIBarButtonItem
,并使用
userInteractionEnabled
而不是
enabled

let saveBarButton = UIBarButtonItem(customView: saveButton)
saveBarButton.customView?.userInteractionEnabled = false

您是否尝试过
sender.tintColor=UIColor(红色:51/255,绿色:51/255,蓝色:51/255,alpha:1.0)
,将按钮设置为enabled=false?有趣的想法…我现在实际上已经更改了代码,所以我根本不需要执行此操作,但感谢您的帮助!我需要的时候会记住的