Resizing UITextView

前端 未结 10 1423
隐瞒了意图╮
隐瞒了意图╮ 2020-12-04 15:52

I have a UITextView added on my UIView. The textview added is not editable, it is just to display some data. The data displayed in the textview is

10条回答
  •  醉梦人生
    2020-12-04 16:32

    After you add the UITextView to its parent if you set a Content Mode on it then it seems to resize itself automatically.

    This means you don't need to work out the height manually and apply a height contraint. It just seems to work!! Tested in iOS7 and iOS8 on iPad.

    e.g.

    --
    textView.contentMode = UIViewContentMode.Center;
    --
    

    If anyone can explain why this works it would be much appreciated.. I found it by accident when messing with options in interface builder.

提交回复
热议问题