Asked 7 years ago
4 Jul 2017
Views 1269
iPhone-coder

iPhone-coder posted

how to apply border to UITextView

how to apply border to UITextView
steave

steave
answered Apr 24 '23 00:00

To add a border to a UITextView in iOS, you can set the borderColor , borderWidth , and cornerRadius properties of the view's layer property.

Here's an example of how to add a border to a UITextView :



myTextView.layer.borderColor = [[UIColor blackColor] CGColor];
myTextView.layer.borderWidth = 1.0;
myTextView.layer.cornerRadius = 5.0;

In this example, we set the border color to black, the border width to 1 point, and the corner radius to 5 points. You can adjust these properties to suit your needs.

You can also add a border to a UITextView in Interface Builder by selecting the text view and opening the Attributes Inspector. Under the "View" section, set the "Border Style" to "Line". From here, you can also adjust the border color, width, and corner radius.

Note that adding a border to a UITextView can affect its intrinsic content size, so you may need to adjust the constraints or frame of the text view to accommodate the border.
Post Answer