swift 实践- 06 -- UITextView
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// 多行文本控件
let textview = UITextView.init(frame: CGRect.init(x: 10, y: 100, width: 200, height: 100))
textview.layer.borderWidth = 1.0
textview.layer.borderColor = UIColor.gray.cgColor
self.view.addSubview(textview)
textview.text = "http://www.baidu.com"
// 是否可编辑
textview.isEditable = true
// 内容是否可选
textview.isSelectable = true
// 属性 font 设置字体, textColor 设置字体颜色, textAlignment 设置对其方式
// 给文中的电话号码和 网址添加自动连接
// textview.dataDetectorTypes = [] // 都不加连接
// textview.dataDetectorTypes = .phoneNumber // 只有电话连接
// textview.dataDetectorTypes = .link // 只有网址加
textview.dataDetectorTypes = .all // 电话和网址都加
// 自定义选择内容后的菜单
// 我们在新闻或者小说的时候, 常常在点选文字后弹出菜单进行选择, 复制等操作, 我们可以在这个菜单上添加一些其他内容
let mail = UIMenuItem.init(title: "邮件", action: #selector(onMail))
let weixin2 = UIMenuItem.init(title: "微信", action: #selector(weixin))
let menu = UIMenuController()
menu.menuItems = [mail,weixin2]
}
func onMail(){
print("邮件")
}
func weixin(){
print("微信")
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
swift 实践- 06 -- UITextView的更多相关文章
- 使用Bootstrap 3开发响应式网站实践06,使用ListGroup、Thumbnails展示内容
□ ListGroup展示内容 当希望把同类型的内容以列表.区块展示的时候,ListGroup是不错的选择. <div class="col-sm-6"> <h3 ...
- swift 实践- 08 -- UISegmentedControl
import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoa ...
- Swift 学习- 06 -- 控制流
// 控制流 // swift 提供了多种控制流结构,包括可以多次执行的 while 循环,基于特定条件选择执行不同分支的 if, guard 和 switch 语句,还有控制流程跳转到其它代码位置的 ...
- 使用Axure RP原型设计实践06,登录验证
登录验证主要功能包括: ● 用户名错误,提示无效用户名,用户名和密码文本框清空● 用户名存在,密码错误,提示密码错误,密码清空,焦点进入密码框● 用户名和密码都正确,验证通过 本篇接着"使用 ...
- 学习swift从青铜到王者之swift闭包06
语法表达式 一般形式:{ (parameters) -> returnType in statements } 这里的参数(parameters),可以是in-out(输入输出参数),但不能设定 ...
- Swift 实践之UIWebView
1.选中工程,点击右键,New File>在iOS下选中Othe>Empty,生成一个.js的脚本文件,将代码粘贴过去保存; var script = document.createEle ...
- swift笔记06
for in循环 for 被乘数 in 1...5{ println("\(被乘数) 乘以 5 等于 \( 被乘数 * 5)"); } let 女神们 = ["小林&q ...
- swift 实践- 14 -- UIScrollView
import UIKit class ViewController: UIViewController ,UIScrollViewDelegate{ override func viewDidLoad ...
- swift 实践- 13 -- UIStepper
import UIKit class ViewController: UIViewController { var stepper: UIStepper! var label: UILabel! ov ...
随机推荐
- idea中配置Springboot热部署
1 pom.xml文件 注:热部署功能spring-boot-1.3开始有的 <!--添加依赖--> <dependency> <groupId>org.sprin ...
- 三十一、Linux 进程与信号——SIGCHLD 信号、kill和raise函数以及alarm函数
31.1 SIGCHLD 信号 子进程状态发生变化(子进程结束)产生该信号,父进程需要使用 wait 调用来等待子进程结束并回收它. 避免僵尸进程 #include <stdio.h> # ...
- oracle 问题查找 error ora-
Error ORA-03113: 通信通道的文件结尾进程 ID: 2232会话 ID: 1250 序列号: 这是oracle 报的错误, 可能这个03113这个编码的错误有很多. 但是要找到是什么原因 ...
- article2pdf (Wordpress plug-in) Multiple vulnerabilities(CVE-2019-1000031, CVE-2019-1010257)
Product: article2pdf (Wordpress plug-in)Product Website: https://wordpress.org/plugins/article2pdf/A ...
- Coursera Deep Learning 2 Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization - week1, Assignment(Regularization)
声明:所有内容来自coursera,作为个人学习笔记记录在这里. Regularization Welcome to the second assignment of this week. Deep ...
- python 的基础 学习第十天函数的初始
1,什么是函数,函数就是封装一个功能. 怎么定义函数. # def my_len():#def 是关键字,定义一个一个函数.#my_len():就是函数名,必须和关键字加一个空格,后面加括号和冒号.d ...
- 自定义Banner
Spring Boot项目启动时,默认的打印样式如下 自定义 在/src/main/resources目录下新建banner.txt,在里面输入要打印的文字即可,例如: 图形制作网站:http://w ...
- 将List的元素通过中文字符串排序
类customer public class Customer { public String name; public int age; Customer(String name, int age) ...
- MongpDB 学习手册 - 索引
//查看数据库以及容量 // show dbs //查看有哪些数据表 // show collections // MongoDB 索引 // 索引通常能够极大的提高查询的效率,如果没有索引,Mong ...
- Javascript - ExtJs - Window组件
1.所有组件都可以放入window,此时子组件不需要配置renderTo,只需要将它们作为window的items子项即可. 2.items子项必须先创建,最后创建window,否则子项不会显示. 3 ...