美文网首页
iOS开发设置控件抗拉升抗压缩属性

iOS开发设置控件抗拉升抗压缩属性

作者: 心成则玲 | 来源:发表于2022-08-03 14:39 被阅读0次

    有时候页面布局两个label会在同一条直线上,我们保证其中一个不被拉升或者压缩,这就用到了抗拉升抗压缩属性,废话不多说,直接上代码:

    - (UILayoutPriority)contentHuggingPriorityForAxis:(UILayoutConstraintAxis)axis NS_AVAILABLE_IOS(6_0);
    - (void)setContentHuggingPriority:(UILayoutPriority)priority forAxis:(UILayoutConstraintAxis)axis NS_AVAILABLE_IOS(6_0);
    
    - (UILayoutPriority)contentCompressionResistancePriorityForAxis:(UILayoutConstraintAxis)axis NS_AVAILABLE_IOS(6_0);
    - (void)setContentCompressionResistancePriority:(UILayoutPriority)priority forAxis:(UILayoutConstraintAxis)axis NS_AVAILABLE_IOS(6_0);
    

    抗拉升抗压缩

    [_distanceLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
    [_distanceLb setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
    

    相关文章

      网友评论

          本文标题:iOS开发设置控件抗拉升抗压缩属性

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