Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set UIBarButtonItem alpha

   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?

like image 904
Nikolay Borisov Avatar asked Nov 21 '16 07:11

Nikolay Borisov


1 Answers

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

like image 143
Sameh Salama Avatar answered Nov 13 '22 01:11

Sameh Salama