let textview = UITextView(frame: CGRectMake(10.0, 10.0, (CGRectGetWidth(self.view.bounds) - 10.0 * 2), 80.0))
self.view.addSubview(textview)
textview.backgroundColor = UIColor.lightGrayColor()
// 字体设置
textview.textAlignment = NSTextAlignment.Left
textview.textColor = UIColor.redColor()
textview.font = UIFont(name: "GillSans", size: 15.0)
// 光标颜色
textview.tintColor = UIColor.greenColor()
textview.editable = true
textview.userInteractionEnabled = true
textview.scrollEnabled = true
textview.showsHorizontalScrollIndicator = true
textview.showsVerticalScrollIndicator = true
// 代理,注意添加代理协议,及实现代理方法
textview.delegate = self
// 添加协议
class ViewController: UIViewController, UITextViewDelegate {
override func viewDidLoa