Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can the border of UITextView or UILabel be set in Storyboard?

I want to set the border of a UITextView or a UILabel in a Storyboard. Can it be done?

Programmatically, it is setBorderColor and setBorderWidth.

But can the border be set in a Storyboard?

like image 721
Doug Null Avatar asked May 20 '13 13:05

Doug Null


People also ask

How to render bold text in uilabel or UITextView?

To render this text properly in UILabel or UITextView, you need to convert it to NSAttributedString. NSAttributedString has built-in support for this conversion. First, we need to convert HTML string to Data. let htmlString = "This is a <b>bold</b> text." let data = htmlString.data(using: .utf8)!

What is UITextView used for?

UITextView supports the display of text using custom style information and also supports text editing. You typically use a text view to display multiple lines of text, such as when displaying the body of a large text document.

How do I display multiple text styles in UITextView?

UITextView supports the display of text using custom style information and also supports text editing. You typically use a text view to display multiple lines of text, such as when displaying the body of a large text document. This class supports multiple text styles through use of the attributedText property.


2 Answers

As was previously pointed out, these properties are part of a layer, not part of a view. But you can still set their values in IB. As hypercrypt pointed out, you can use User Defined Runtime Attributes. Since all views have a "layer" property, you can set "layer.borderWidth" for instance.

Here's a case, where I'm changing the cornerRadius. Works great.

enter image description here

like image 74
Dan Morrow Avatar answered Sep 23 '22 23:09

Dan Morrow


use simple code in .m,it show border in view

view.layer.cornerRadius = 5.0f; view.layer.masksToBounds = NO; view.layer.borderWidth = .5f; view.layer.shadowColor = [UIColor orangeColor].CGColor; view.layer.shadowOpacity = 0.4; view.layer.shadowRadius = 5.0f; 
like image 23
NANNAV Avatar answered Sep 19 '22 23:09

NANNAV