美文网首页
代码约束

代码约束

作者: 友田香菜 | 来源:发表于2018-01-17 22:47 被阅读6次

    let coverWidth = NSLayoutConstraint(item: coverImageView, attribute: .width, relatedBy: .equal, toItem: coverImageView.superview, attribute: .width, multiplier: 1, constant: 0)
    let coverHeight = NSLayoutConstraint(item: coverImageView, attribute: .height, relatedBy: .equal, toItem: coverImageView.superview, attribute: .height, multiplier: 1, constant: 0)
    coverWidth.isActive = true
    coverHeight.isActive = true

    image.png

    item:约束的组件
    attribute:约束的属性
    relatedBy:怎么约束?
    tiltem:和谁约束
    attribute:和它的什么属性约束
    multiplier:倍数

    converWidth.Active = true 约束生效

    相关文章

      网友评论

          本文标题:代码约束

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