美文网首页
总结下masonry使用

总结下masonry使用

作者: 苏渝粤 | 来源:发表于2015-06-08 17:33 被阅读2532次

    1 先从问题说起:将masonry封装进了sdk后,在其他程序中调用即崩溃,报unrecognized selector sent to instance错误

    查了很久,在stockoverflow上找到解决方法:是调用sdk的时候没有在flag中加入-Objc 和-all_load

    Make sure you have linked the Masonry static library successfully if you didn't use cocoapods, besides, Masonry mainly expands some objective-c categories for UIKit/AppKit, so you had better check the following links out. Briefly, you should add flag -ObjC and -all_load to your project's "Other linker flags".

    如图位置:

    2 在使用masonry的时候注意几个方法几个参数就可以了

    1 left/right/top/bottom/leading/trailing/width/height/centerX/centerY/baseline

    几个参数都很好理解,left/right与leading/trailing意义相同,部分使用情况不同(暂时没用到),可以直接食用leading/trailing

    2 - (NSArray*)MAS_makeConstraints:(void(^)(MASConstraintMaker*make))block;

    添加约束

    - (NSArray*)MAS_updateConstraints:(void(^)(MASConstraintMaker*make))block;

    更新约束

    - (NSArray*)MAS_remakeConstraints:(void(^)(MASConstraintMaker*make))block;

    删除原来的所有约束

    3 具体使用,1个例子就明白了

     [self.button1 MAS_makeConstraints:^(MASConstraintMaker*make) {

    make.centerX.equalTo(self.view);//横向中点父类

    make.top.equalTo(self.view).with.offset(kScreenHeight/2-35);

    make.size.MAS_equalTo(CGSizeMake(150,50));

    }];

    相关文章

      网友评论

          本文标题:总结下masonry使用

          本文链接:https://www.haomeiwen.com/subject/lvfjqttx.html