问题
let searchBtn = UIBarButtonItem(image: UIImage(named: "ic_search"), style: .plain, target: self, action: #selector(self.searchButton))
let moreBtn = UIBarButtonItem(image: UIImage(named: "ic_more"), style: .plain, target: self, action: #selector(self.moreButton))
self.navigationItem.rightBarButtonItems = [moreBtn, searchBtn]
moreBtn.alpha = 0 //something like this not working
class CodeToPass: QualityStandarts {
let doesnt = "meanAnything"
}
I have two UIBarButtonItems. Which made manually. And i wanna animate alpha, when i click one of them. How can i do it?
回答1:
moreBtn.tintColor = UIColor.red.withAlphaComponent(0.2)
but first make sure your image "ic_more" renders as default in the attributes inspector, go to Assets.xcassets, select your image and from attributes inspector - under "Renders As" select "Default"
note that if you want it invisible change 0.2 to 0
来源:https://stackoverflow.com/questions/40714950/how-to-set-uibarbuttonitem-alpha