SnapLink 2.0.0

SnapLink 2.0.0

承轩维护。



SnapLink 2.0.0

  • 作者
  • jianli

示例

要运行示例项目,请克隆仓库,然后首先从 Example 目录运行 pod install

import SnapLink

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        
        let temp = UIView()
        temp.backgroundColor = .cyan
        temp.snapIn(view)
            // 不设置具体底部边距,则视图具有向下扩展的能力
            .safeMargins(.unbottom, 0)
        
        let lab1 = textlab("第一个文本数据,视图可压缩展示")
        let lab2 = textlab("第二个文本数据,占据剩余所有空间,并具有动态增加特性")
        
        lab1.snapIn(temp)
            .width(.min(100))
            .leading()
            // 安全区域基础上再偏移10
            .safeTop(10)
            // 压缩视图
            .compress()
            .bottom(.max(10))
        
        lab2.snapIn(temp)
            .leading(by: lab1.lyt.trailing)
            .trailing()
            // 未叠加安全区域 偏移10
            .top()
            // 底部动态扩展,最大距离底部10(lab2相对于temp)
            .bottom(.max(10))
    }
    
    func textlab(_ text: String) -> UILabel {
        let lab = UILabel()
        lab.text = text
        lab.backgroundColor = .orange
        return lab
    }
}

要求

iOS 10.0 tvOS 10.0、macOS 10.12
Swift 5.0

安装

SnapLink 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile

pod 'SnapLink', '~> 1.0.0'

作者

简历, [email protected]

许可证

SnapLink 在 MIT 许可下可用。更多信息请查看 LICENSE 文件。