Planning to use the same text view in multiple places in the app so planning to create text view component without xib/Storyboard so that the same can be reuse in multiple places.
I’m a junior developer how can we create a text view component programmatically which can display two lines of text as shows in below screenshot.
Created a class of text view and trying to add text in it. please advice/suggest the flow to implement this.
@IBDesignable public class HyperLinksTextView: UITextView {
required public init?(coder: NSCoder) {
super.init(coder: coder)
self.backgroundColor = .clear
createTextView()
}
func createTextView() {
}
}
2
Answers
try this 🙂
If you need to display static text with no editing features and no selection features, you should use a
UILabel
.If you need selection or editing, use UITextView.
For Creating UILabel Subclass for using everywhere:
And here’s how you use it in your View Controller:
import UIKit
class ViewController: UIViewController {