[整理]swift的视图的布局的约束

搜:

swift view Layout Constraints

参考:

搜:
然后可以把复杂的布局,写成很简单的形式

比如

import Cartography

        self.view.addSubview(self.logoImageView)

        //1. logo image
        self.logoImageView.image = LoginLogoImage
        self.logoImageView.contentMode = .Center
        self.logoImageView.backgroundColor = AppMainColor
        constrain(self.logoImageView) {logoImageView in
            logoImageView.top == logoImageView.superview!.top
            logoImageView.centerX == logoImageView.superview!.centerX
            logoImageView.height == LoginLogoImageHeigh
            logoImageView.width == UIScreen.mainScreen().bounds.width
        }

即可。



发表评论

电子邮件地址不会被公开。 必填项已用*标注

无觅相关文章插件,快速提升流量