2016-11-21 2 views
1
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" 
    } 

私は2つのUIBarButtonItemを持っています。どちらが手作りですか。そして私はアルファをアニメーションしたいと思います。どうすればいいですか?最初UIBarButtonItemを設定する方法

+0

は、もっとボタンにアニメーションを適用したいということを意味します。 –

答えて

2
moreBtn.tintColor = UIColor.red.withAlphaComponent(0.2) 

が、「ic_more」あなたのイメージは、属性インスペクタでデフォルトとしてレンダリングすることを確認し、 は、Assets.xcassetsに行くあなたのイメージを選択し、属性インスペクターから - 「としてレンダリング」の下の「デフォルト」

を選択します

あなたがそれを目に見えないようにするには、0.2から0に変更してください。

+0

私はこのUIView.animate(withDuration:0.5、animations:{ self.navigationItem.rightBarButtonItems?[0] .tintColor = UIColor.red.withAlphaComponent(0.0) self.navigationItem.rightBarButtonItems?[0]。 tintColor = UIColor.green.withAlphaComponent(0.0) self.navigationItem.rightBarButtonItems?[0] .tintColor = UIColor.blue.withAlphaComponent(0.0) } –

関連する問題