У меня есть этот код для подкласса UITableViewCell,
final class SettingsTableViewCell: UITableViewCell {
// MARK:- Properties
var switchControl: UISwitch = {
let switchControl = UISwitch()
switchControl.isOn = true
return switchControl
}()
// MARK: - Initializers
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
commonInit()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// MARK:- Methods
private func commonInit() {
layer.isOpaque = true
backgroundColor = .backgroundColor
configureSwitchControl()
}
private func configureSwitchControl() {
switchControl.addTarget(self, action: #selector(handleSwitchAction), for: .valueChanged)
addSubview(switchControl)
switchControl.translatesAutoresizingMaskIntoConstraints = false
switchControl.rightAnchor.constraint(equalTo: safeAreaLayoutGuide.rightAnchor, constant: -12).isActive = true
switchControl.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
}
// MARK:- Actions
@objc private func handleSwitchAction(sender: UISwitch) {
}
}
Он отлично работает на симуляторе iPhone X,
![enter image description here](https://i.stack.imgur.com/BSuzJ.png)
But on an iPad Pro(9.7-inch) simulator I have this shift,
введите описание изображения здесь
ModalPresentationStyle не является полноэкранным. Есть ли способ исправить это, не меняя константу заполнения?