我正在使用 Xcode 版本 13.4 (13F17a),我正在嘗試使用 UIKit 學習 iOS 開發,但我無法找到要添加到情節提要的元素(即按鈕、文本欄位),這迫使我以編程方式進行設計
`
class ButtonDesign:UIButton{
func buttonUiDesign() -> UIButton{
let buttonX = 150
let buttonY = 150
let buttonHeight = 50
let buttonWidth = 100
let button = UIButton(type: .system)
button.setTitle("Click me!!", for: .normal)
button.tintColor = .blue
button.backgroundColor = .red
button.addTarget(self, action: #selector(buttonClicked), for: .touchUpInside)
button.frame = CGRect(x: buttonX, y: buttonY, width: buttonWidth, height: buttonHeight)
return button
}
//Notification Using Haptic Engine when clicked.
@objc func buttonClicked(sender:UIButton){
// let alert = UIAlertController(title: "clicked", message: "you have clicked the button", preferredStyle: .alert)
// self.present(alert, animated: true, completion:nil)
let impact = UIImpactFeedbackGenerator()
impact.impactOccurred()
}
下面是 main.storyboard 的圖片,有人可以教育我。我想將選擇的元素拖放到 viewcontroler。我為我的英語道歉,我正在使用谷歌翻譯。下面是我的 main.storyboard
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/507536.html
