美文网首页
xib、storyboard、masonry混用

xib、storyboard、masonry混用

作者: CombatReadiness | 来源:发表于2019-03-13 15:55 被阅读0次

有些时候我们在xib、storyboard中布置好约束后,想在某些时候使用代码改变约束,我习惯用masonry,可能会出现的问题是:

Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)

这就是出现了约束冲突,在此语句下,系统会告知约束冲突的地方。怎么解决?
像我们使用xib在view上布局一个button,xib上把约束弄好后,以button上边距离父视图上边举例,想在某个时候不动xib约束,然后又可用代码控制,masonry可这样写

[self.button mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view.mas_top).offset(3);
 }];

然后xib中要把button上边距离父视图上边的约束的优先级不使用默认1000了,使用750,即降低优先级,这样就行了,storyboard同。


屏幕快照 2019-03-13 15.52.45.png

相关文章

  • xib、storyboard、masonry混用

    有些时候我们在xib、storyboard中布置好约束后,想在某些时候使用代码改变约束,我习惯用masonry,可...

  • xib、storyboard、masonry混用

    有些时候我们在xib、storyboard中布置好约束后,想在某些时候使用代码改变约束,我习惯用masonry,可...

  • Masonry

    Masonry概述 Masonry,很好用的框架,不需要使用XIB和Storyboard,手写代码简约方便,有很好...

  • 入住简书

    加入,稍后几天有时间的话会写一篇关于storyboard和xib混用的黑魔法文章

  • Masonry的适配

    1.为什么选择Masonry iOS的自动布局,可以使用xib/storyboard和frame(即代码)来适...

  • 使用IB_DESIGNABLE动态查看视图,修改Masonry纯

    公司里禁用xib(storyboard)来布局,只好使用[Masonry]来写布局约束,疼痛减轻不少;但每次都要的...

  • 使用Storyboard动态修改约束

    很好用的第三方约束框架“Masonry”,可以随时修改约束: 现在,我们需要在Storyboard或xib中动态修...

  • iOS生命周期

    生命周期如下: xib/storyboard:-initWithCoder:,而非xib/storyboard的是...

  • Masonry如何约束宽高相等

    其实Masonry封装的API和苹果官方的思路是非常一致的,如果你经常用storyBoard或者Xib来自动布局的...

  • ios 页面跳转

    xib跳到Storyboard UIStoryboard *storyboard = [UIStoryboard ...

网友评论

      本文标题:xib、storyboard、masonry混用

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