美文网首页
showMessage方法、Auto Layout布局约束

showMessage方法、Auto Layout布局约束

作者: Suiyuewuyang | 来源:发表于2019-01-15 23:26 被阅读0次

    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 + 拖拽 来设定约束条件
    

    相关文章

      网友评论

          本文标题:showMessage方法、Auto Layout布局约束

          本文链接:https://www.haomeiwen.com/subject/xrbgrqtx.html