搜:
swift view Layout Constraints
参考:
搜:
swift constraints programmatically
参考:
然后可以把复杂的布局,写成很简单的形式
比如
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 }
即可。
转载请注明:在路上 » [整理]swift的视图的布局的约束