创建TextView
let textView = UITextView(frame: CGRectMake(50, 100, 280, 50)) self.view.addSubview(textView)
设置边框
textView.layer.borderWidth = 1//边框宽度 textView.l
常用属性
textView.editable = true//是否可以编辑 textView.selectable = true//内容是否可选 textView.font = UIFont.systemFontOfSize(20)//字体大小 textView.textColor = UIColor.blackColor()//字体颜色 textView.textAlignment = .Left//文字对齐方式
显示链接方式
textView.dataDetectorTypes = UIDataDetectorTypes.None//都不加链接 textView.dataDetectorTypes = UIDataDetectorTypes.PhoneNumber//只有电话加链接 textView.dataDetectorTypes = UIDataDetectorTypes.Link//网址加链接 textView.dataDetectorTypes = UIDataDetectorTypes.All//电话和网址都加链接
自定义菜单
let mail = UIMenuItem(title: "邮件", action: "omMail") let weixin = UIMenuItem(title: "微信", action: "onWeiXin:") let menu = UIMenuController() menu.menuVisible = true menu.menuI