How to style UITextview to like Rounded Rect text field?

后端 未结 20 2364
深忆病人
深忆病人 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:20

    #import 
    - (void)viewDidLoad{
      UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(50, 220, 200, 100)];
      textView.layer.cornerRadius = 5;
      textView.clipsToBounds = YES;
      [textView.layer setBackgroundColor: [[UIColor whiteColor] CGColor]];
      [textView.layer setBorderColor: [[UIColor grayColor] CGColor]];
      [textView.layer setBorderWidth: 1.0];
      [textView.layer setCornerRadius:8.0f];
      [textView.layer setMasksToBounds:YES];
      [self.view addSubView:textview];
    }
    

提交回复
热议问题