ios – 在xCode中包装内容UILabel

前端之家收集整理的这篇文章主要介绍了ios – 在xCode中包装内容UILabel前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试制作一个在同一行上有两个UILabel的单元格.
像这样:

User Name: blablabla

用户名是第一个UILabel,blablabla是第二个UILabel.

我希望第一个UILabel包装内容,第二个将其内容扩展到超级视图的尾随.

我试图围绕StackOverflow寻找我的问题的答案,但我找不到一个.有人知道我怎么能实现这一目标?

我想要这样的东西:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

    <TextView
        android:id="@+id/first_label"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="User Name:"/>

    <TextView
        android:id="@+id/second_label"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="bla bla bla"/>

</LinearLayout>

或者像这样

<android.support.constraint.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <TextView
        android:id="@+id/first_label"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="User Name:"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent"/>

    <TextView
        android:id="@+id/second_label"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="bla bla bla"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toRightOf="@id/first_label"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"/>

</android.support.constraint.ConstraintLayout>

解决方法

尝试更改内容压缩阻力优先级

看看这些快照:

具有默认内容压缩阻力优先级的标签

enter image description here

我改变了标签blablabla blablabla的内容抗压性优先级,从750到749.

结果是:

enter image description here

猜你在找的Xcode相关文章