1
にはUIButton
があります。それは白いUIColor
と橙色の強調表示された色をしています。色をハイライトされた色から別の色に直接切り替える
ボタンを選択した直後にこのボタンの色を変更したいと思います。次のコードで
理想的な結果
White(default) -> orange(highlighted) -> green(animated) -> white(default)
しかしながら、橙色から緑色に色が変化する前に、それはすぐに白色となります。
現在の結果
White(default) -> orange(highlighted) -> White(default) -> green(animated) -> white(default)
は、どのように私は緑色にハイライト表示され、オレンジ色から直接色を切り替えることができますか?
UIView.animate(withDuration:0, animations: {() -> Void in
cell.buttons[index].backgroundColor = UIColor.green
}) { (Bool) -> Void in
UIView.animate(withDuration: 0.5, animations: {() -> Void in
cell.buttons[index].backgroundColor = UIColor.green
}, completion: { (Bool) -> Void in
UIView.animate(withDuration: 0, animations: {() -> Void in
cell.buttons[index].backgroundColor = UIColor.white
}, completion:nil)
})
}
あなたのUIButtonのタイプは何ですか?ストーリーボードでカスタムに設定されていることを確認してください。 –
あなたのボタンにオレンジの "ハイライトされた色"を得るためにどのような方法を使用していますか? – DonMag