现在我正在做一个自定义键盘项目,当我单击 ABC 辅助键盘按钮时,我想要一个按钮将键盘从“键盘 1”更改为键盘“2”。对于 RowA1 和 RowA3,我只需要更改按钮标题,它工作正常。
我的问题是我应该如何进行这项工作。
现在,我有一个按钮,根据它的按钮标签,然后尝试设置前导和尾随。但似乎这种方式行不通。
有人能告诉我,我的代码有什么问题吗?
键盘1
键盘2
import UIKit
import Foundation
import AudioToolbox
class KeyboardViewController: UIInputViewController {
@IBOutlet weak var RowA2: UIStackView!
@IBOutlet weak var SecondaryKeyboardButton: UIButton!
@IBAction func updateSecondaryKeyboardStatus(_ sender: UIButton) {
if sender.titleLabel?.text == "ABC" {
RowA02Aligment = 27
}
if sender.titleLabel?.text != "ABC" {
RowA02Aligment = 4
}
RowA2.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: RowA02Aligment).isActive = true
RowA2.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: RowA02Aligment).isActive = true
RowA2.isHidden = false
}
override func viewDidLoad() {
super.viewDidLoad()
shiftStatus = 0
DeleteCount = 0
}
}