Я создаю UIButton, который отображается внутри XIB. Но когда я добавляю модификацию для дисплея iPhone X, я не могу вызвать метод внутри его действия. Вот код ниже:
@IBOutlet weak var tryAgainButton: UIButton!
@IBAction func tryAgainButtonPressed(_ sender: UIButton) {
myFunction()
}
if UIDevice().userInterfaceIdiom == .phone, // Iphone X
UIScreen.main.nativeBounds.height == 2436 {
label.font = label.font.withSize(12)
contentView.snp.makeConstraints { make in
make.centerY.equalToSuperview()
make.top.equalToSuperview().offset(-20)
containerView.backgroundColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
contentView.backgroundColor? = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
containerView.backgroundColor? = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
label.textColor = #colorLiteral(red: 0, green: 0, blue: 0, alpha: 1)
helpButton.setTitleColor(#colorLiteral(red: 0, green: 0, blue: 0, alpha: 1), for: .normal)
tryAgainButton.setTitleColor(#colorLiteral(red: 0, green: 0, blue: 0, alpha: 1), for: .normal)
let underlineAttributes : [NSAttributedStringKey: Any] = [
NSAttributedStringKey.underlineStyle : NSUnderlineStyle.styleSingle.rawValue,
NSAttributedStringKey.foregroundColor : #colorLiteral(red: 0, green: 0, blue: 0, alpha: 1)
]
let helpButtonAttributeString = NSMutableAttributedString(string: "Help",
attributes: underlineAttributes)
let tryAgainButtonAttributeString = NSMutableAttributedString(string: "Try Again",
attributes: underlineAttributes)
helpButton.setAttributedTitle(helpButtonAttributeString, for: .normal)
tryAgainButton.setAttributedTitle(tryAgainButtonAttributeString, for: .normal)
}
}
myFunction()
недоступно при работе с Iphone X.