zoukankan      html  css  js  c++  java
  • swift 约束

     这里tableview 是从最顶上的安全区适配的, nextBtn是最下边从安全区设置的,如果是在中间的view还是原来的写法,看2
      1.安全区适配适用于Vc里面, 如果是自定义的view或封装的view, 直接使用原来写法就可以了
     2        tableview.snp.makeConstraints { (make) in
     3             if #available(iOS 11.0, *) {
     4                 make.top.equalTo(self.view.safeAreaLayoutGuide.snp.top)
     5             } else {
     6                 make.top.equalTo(self.topLayoutGuide.snp.top)
     7             }
     8 
     9             make.centerY.equalTo(view)
    10             make.width.equalTo(view)
    11             make.bottom.equalTo(view).inset(-60)
    12         }
    13         
    14         view.addSubview(nextBtn)
    15         nextBtn.snp.makeConstraints { (make) in
    16             
    17             make.left.equalTo(tableview)
    18             make.right.equalTo(tableview)
    19             if #available(iOS 11.0, *) {
    20                 make.bottom.equalTo(self.view.safeAreaLayoutGuide.snp.bottom)
    21             } else {
    22                 make.bottom.equalTo(self.bottomLayoutGuide.snp.bottom)
    23             }
    24             make.height.equalTo(60)
    25         }
    26 
    27 
    28       2. 非安全区写法还和原来一样
    29 
    30         titleLabel.snp.makeConstraints { (make) in
    34             make.left.equalTo(view).offset(24)
    38             make.top.equalTo(view).offset(24) }


         3.iOS - 约束 - VFL 和auto layout 安全区适配
    1         if #available(iOS 11.0, *) {
    2             tableview.translatesAutoresizingMaskIntoConstraints = false
    3             tableview.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor).isActive = true
    4         } else {
    5             tableview.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
    6         }
    详情使用链接 :SnapKit的详细使用介绍 :https://www.jianshu.com/p/2bad53a2a180

    swift约束之SnapKit的使用方式 : https://blog.csdn.net/w_shuiping/article/details/50973035

      

  • 相关阅读:
    ld -l选项注意事项
    linux下创建用户(转)
    delete void *
    __attribute__机制介绍(转)
    正常断开连接情况下,判断非阻塞模式socket连接是否断开
    std::thread “terminate called without an active exception”
    Android 开发手记二 C可执行程序编译实例(转帖)
    c++11 on Android
    由一段小程序看算法复杂度
    Linux守护进程的编程实现(转)
  • 原文地址:https://www.cnblogs.com/qingzZ/p/9242928.html
Copyright © 2011-2022 走看看