0
버튼 제목의 배경을 수정하려고합니다. 그리고 여기 blue.png에서 green.png로 전환하는 동안 발생합니다. 버튼을 클릭하면 버튼의 배경이 blue.png으로 표시되고 버튼은 녹색으로 표시됩니다.제목 배경에 애니메이션을 적용하면서 UIButton을 클릭하면 도청 된 동작이 표시됩니다.
전체 버튼은 동일한 green.png로 표시되어야합니다. 그리고 UIView.transition
을 제거하면 올바르게 작동합니다. XIB에서의 ViewController에서
@IBOutlet weak var option_1: UIButton!
func optionsAnimateGreen(){
let options = [option_1]
let stop = [stop_1]
for (option, stopper) in zip(options, stop){ //loops options and stop
let btn:UIButton = option!
if stopper{
UIView.transition(with: btn, duration: 1.5, options: [ .transitionCrossDissolve, .allowUserInteraction], animations: {
btn.toggleSelection()
}, completion: nil)
}
}
}
self.timer = Timer.scheduledTimer(timeInterval: 1.5, target: self, selector: #selector(self.optionsAnimateGreen), userInfo: nil, repeats: true);
extension UIButton {
func toggleSelection() {
self.isSelected = self.isSelected ? false : true
}
}
: 버튼 배경의 기본 상태는 blue.png로 설정 버튼 배경의 선택 상태에 대해이 당신은있는 UIButton 변경해야
. 나는 그 문제가 무엇인지 찾기 위해 고심하고있다. 감사. – Prateekro