Comments 3
Далее закрепляем его констрейнтами с отступом в 2 pix со всех сторон.
Вот поэтому Interface Builder — зло.
Это всё равно, что в коде дублировать литералы, не пользуясь константами.
Да, как здесь:
@IBAction func buttonOne(_ sender: UIButton) {
checkButtonOne.priority = UILayoutPriority(rawValue: 950)
checkButtonTwo.priority = UILayoutPriority(rawValue: 750)
UIView.animate(withDuration: 0.5) {
self.view.layoutIfNeeded()
}
}
@IBAction func buttonTwo(_ sender: UIButton) {
checkButtonOne.priority = UILayoutPriority(rawValue: 750)
checkButtonTwo.priority = UILayoutPriority(rawValue: 950)
UIView.animate(withDuration: 0.5) {
self.view.layoutIfNeeded()
}
}
Есть намного более причесанная версия, да еще и с наследованием от UIControl.
github.com/TimOliver/TOSegmentedControl
github.com/TimOliver/TOSegmentedControl
Sign up to leave a comment.
Segmented Control своими руками, как в iOS 13.0 и выше