나는 몇 가지 이상한 행동을 배열의 버튼이 나는 내장 된 스토리. 내가 있는 4 개 버튼의 각 사용자 지정 형식 TakesContainerButton
을 때 버튼을 클릭하면 그것을 변경하는 시스템의 글꼴이지만,때 다른 버튼을 클릭하면 이전에 버튼을 반환하고 원하는 글꼴을 확실하지 않 여기에 무슨 일이 일어나고 있는지에
이튼은 또한 임베디드 스택에서 보면,문제
여기에 구현할 때는 하나의 단추를 누르는 곳 buttons
배열의 버튼 4
@IBAction func filterPressed(_ sender: TakesContainerButton) {
for button in buttons {
button.unclick()
}
sender.click()
}
여기에는 사용자 정의 클래스
class TakesContainerButton: UIButton {
var bottom = UIView()
func click(){
self.setTitleColor(.darkGray, for: .normal)
let xOffset:CGFloat = 10
bottom = UIView(frame: CGRect(x: xOffset / 2, y: self.frame.height - 3, width: self.frame.width - xOffset, height: 3))
bottom.layer.cornerRadius = 1.5
bottom.backgroundColor = .darkGray
self.addSubview(bottom)
}
func unclick(){
bottom.removeFromSuperview()
self.setTitleColor(UIColor(hex: "8B8B8B"), for: .normal)
}
override func awakeFromNib(){
setFont()
}
func setFont(){
self.titleLabel?.font = UIFont(name: "Lato-Bold", size: 12)
}
}