Swift如何使用Masonry和SnapKit

來源:互聯網
上載者:User

SnapKit:

https://github.com/SnapKit/SnapKit


v.snp_makeConstraints { (make) in

由於swift和oc文法不一樣 equalTo(self.view)是傳入參數       

        make.top.equalTo(self.view).offset(100)

            make.left.equalTo(self.view).offset(100)

            make.right.equalTo(self.view).offset(-100)

            make.bottom.equalTo(self.view).offset(-100)

            

            

        }


Masonry: 

https://github.com/SnapKit/Masonry


由於swift和oc文法不一樣 equalTo()是先調用get方法  

v.mas_makeConstraints { (make) in

            make.top.equalTo()(self.view).setOffset(100)

            make.left.equalTo()(self.view).setOffset(100)

            make.right.equalTo()(self.view).setOffset(100)

            make.bottom.equalTo()(self.view).setOffset(100)

        }

相關文章

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.