How to style UITextview to like Rounded Rect text field?

后端 未结 20 2336
深忆病人
深忆病人 2020-11-28 00:36

I am using a text view as a comment composer.

In the properties inspector I can\'t find anything like a border style property so that I can make use a rounded rect,

20条回答
  •  借酒劲吻你
    2020-11-28 01:12

    One solution is to add a UITextField below the UITextView, make the UITextView background transparent and disable any user interaction on the UITextField. Then in code change the UITextField frame with something like that

    self.textField.frame = CGRectInset(self.textView.frame, 0, -2);
    

    You will have exactly the same look as a text field.

    And as suggested by Jon, you should put this piece of code inside [UIViewController viewDidLayoutSubviews] on iOS 5.0+.

提交回复
热议问题