swift点击button显示button文字的代码和点击button切换到新建页面NewViewController的代码用@objc
时间: 2023-06-06 08:07:27 浏览: 157
ios demo,代码创建按钮button
func getButtonCode() {
// Swift 点击 Button 显示 Button 文字的代码
let button = UIButton()
button.setTitle("Button Title", for: .normal)
button.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)
}
@objc func buttonTapped() {
// 点击 Button 切换到新建页面 NewViewController 的代码
let newVC = NewViewController()
self.navigationController?.pushViewController(newVC, animated: true)
}
阅读全文