当字体变大时,如何将一个约束优先于另一个约束

时间:2018-03-24 17:39:54

标签: ios swift nslayoutconstraint

我有一个具有以下限制条件的UILabel:

static int getPuid (int gpid) 
{ // by Zibri http://www.zibri.org
    char fname[256];
    char buf[256];
    int pid=8;
    sprintf(fname,"/proc/%d/status",gpid);
    FILE *proc; 
    proc = fopen(fname,"r");    
    if (proc) { 
        while(pid--) fgets(buf,256,proc); // skip first 8 lines
        sscanf(buf,"Uid:\t%lu\t",&pid); 
    } else return -1;   
    fclose(proc);   
    return pid;
}

在正常模式下, - Align Center Y to Superview (priority 750) - Top Space to View, greater than equal to 0 (priority 1000) UILabel即可。但是,如果我转到align center to Y设置并设置为大字体(最大大小),我希望我的标签使用大于等值的Accessibility

目前在这两种情况下仍然使用Top Space。有没有办法在字体很大时使用具有更高优先级的其他约束?

PS:在此标签下方还有2个其他标签在字体较大时会缩小,因为顶视图标签位于屏幕中间而不是向上移动。

1 个答案:

答案 0 :(得分:1)

试试这个

- Bottom space to view, equal to zero (multiplier 2)
- Top Space to View, greater than equal to 0  

截图

enter image description here

enter image description here

enter image description here

项目 - https://github.com/leninsmannath/AutoLayoutBottomFromCenter.git