swift下面使用第三方Masonry 的代碼

來源:互聯網
上載者:User


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)

        }


相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.