简体   繁体   中英

How resize UIView With inner UITextView using Autolayout?

Hi i want to know how to use autolayout to achieve this behavior:

  • In picture #1 is my viewcontroller contains with 3 uiview embedded with uitextview , as you can see the uiview dont allow the uitextview to show its full text.
  • So i want to know how could i use autolayout to resize the uiview in order that inner uitextview can show the full text like picture #2.

Picture #1:

在此处输入图片说明


Picture #2:

在此处输入图片说明

Considering that the size of ui view container increases with the description text Here is an approach you can follow.Use a uilabel instead of uitextview. Structure

<UIView>
     <UILabel for header>
     </UILabel>
    <UILabel for text>
     </UILabel>
</UiView>

1)Add a top spacing constraint between header uilabel and uiview

2)Add a bottom spacing constraint between text uilabel and uiview.

3)Add a spacing constraint between 2 uilabels

3)Add a height constraint for the description uilabel .Obtain height for the uilabel based on this Adjust UILabel height depending on the text and then add the required height.

Also if you instead want fixed height for uiview then you will have to use uitextview instead of desc uilabel and add scrollable property to texview.

我设置了一个简单的项目,可以在iOS 8中成功调整大小。请参阅GitHub上的项目。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM