UIButton에서 두 개의 이미지 (애니메이션 포함)를 토글해야하지만 UIButton에서 내 이미지 뒤에 내 레이블을 숨 깁니다. 그래서 나는 그것에 UILabel의 하위 뷰를 추가했고 그것은 또한 보이지 않는다. 심지어 전방에 서브 뷰를 가져 오려고했지만 그것도 작동하지 않습니다.버튼 이미지를 애니메이트 할 때 UIButton 텍스트가 표시되지 않습니다.
let options = [option_1, option_2, option_6]
var imageArray = [UIImage]()
imageArray.append(UIImage(named: "light_button.png")!)
imageArray.append(UIImage(named: "dark_button.png")!)
let label = UILabel(frame: CGRect(x: 0, y: 0, width: self.option_1.frame.width, height: self.option_1.frame.width))
label.text = "HEY"
label.font = UIFont.systemFont(ofSize: 18)
option_1.addSubview(label)
option_1.bringSubview(toFront: label)
for option in options{
option?.setImage(UIImage(named: "green_button.png")!, for: .normal)
option?.imageView!.animationImages = imageArray
option?.imageView!.animationImages = imageArray
option?.setTitle("TEST TEXT", for: .normal) //Even this don't work
option?.imageView!.animationDuration = 2.35
option?.imageView!.startAnimating()
}
무엇이 잘못 되었습니까?
옵션 배열에 무엇을 추가 했습니까? – Ishika
@ishika 이들은 UIButtons입니다. – Prateekro
아울렛을 만들거나 버튼을 프로그래밍 방식으로 만들지 않았습니까? – Ishika