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?
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)!
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.
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.
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.
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With