★ ボタン、セル、ナビゲーションアイテム、セグメントコントロールの同時押しを制御する
※ storybosard
,xib
用
extension UIButton {
open override func awakeFromNib() {
self.isExclusiveTouch = true
}
}
extension UITableViewCell {
open override func awakeFromNib() {
self.isExclusiveTouch = true
}
}
extension UINavigationController {
open override func awakeFromNib() {
self.navigationBar.isExclusiveTouch = true
}
}
extension UISegmentedControl {
open override func awakeFromNib() {
self.isExclusiveTouch = true
}
}
- appearanceでの設定
/* Exclusive Touch */
UIButton.appearance().isExclusiveTouch = true
UITableViewCell.appearance().isExclusiveTouch = true
UICollectionViewCell.appearance().isExclusiveTouch = true
UINavigationBar.appearance().isExclusiveTouch = true