In this short Swift code example, you will learn how to create UITextView programmatically in Swift.
- Create UITextView programmatically
- Position UITextView at a specific location within a view
- Position UITextView at the center of the view
- Change UITextView text color
- Change UITextView background color
let textView = UITextView(frame: CGRect(x: 20.0, y: 90.0, width: 250.0, height: 100.0)) textView.contentInsetAdjustmentBehavior = .automatic textView.center = self.view.center textView.textAlignment = NSTextAlignment.justified textView.textColor = UIColor.blue textView.backgroundColor = UIColor.lightGray
For more Swift code examples and tutorials, please check the Swift Code Examples page on this website.