1. 使用cocoapods 加载三方( pod 'Masonry')
2.桥联
先建立 (.h)
3.(.h)参照官方命名Header-Briding-Header,将Masonry引入文件中
4.在Build Setting 中搜索bridging 找到Objective-C Bridging Header 并且将建立的(.h) 文件路径写入
5.然后就可以正常使用了
例如:
//使用masonry
let label1 =UILabel()
self.view .addSubview(label1)
label1.text ="新建的"
label1.backgroundColor =UIColor.blueColor()
label1.textAlignment =NSTextAlignment.Center
label1.mas_makeConstraints { (make:MASConstraintMaker!)in
make!.left.mas_equalTo()(15)
make.right.mas_equalTo()(self.view.mas_right).setOffset(-15)
make.height.mas_equalTo()(45)
make.top.mas_equalTo()(300)
}