showMessage方法
func 关键字定义一个方法
@IBAction 将代码与介面建构器的使用者介面物件做连结
import UIKit 导入UIKit架构
// 呼叫 addAction 方法来加入一个动作
例:alertController.addAction
(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: nil))
完整代码如下:
let alertController = UIAlertController
(title: "Meaning", message:meaning, preferredStyle: UIAlertController.Style.alert)
alertController.addAction
(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: nil))
present(alertController,animated: true,completion: nil) //输出
Auto Layout布局约束

auto-layout-4.png
Align:建立对齐的约束条件,例如对齐两个视图的右侧
Pin/Add new Constraints:建立间距的约束条件
Resolve auto layout issues:解决布局问题
Stack:视图嵌入至堆叠式图中
Update frames:以设定的约束条件来更新框架的位置与尺寸
// Control + 拖拽 来设定约束条件
网友评论