swift 实践- 03 -- UILabel
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// 标签
let label: UILabel = UILabel(frame: CGRect(x: 100, y: 250, width: 200, height: 100))
label.text = "Hello world!"
self.view.addSubview(label)
label.textAlignment = .center
// 设置文本高亮
label.isHighlighted = true
// 设置文本高亮颜色
label.highlightedTextColor = UIColor.black
// 富文本设置
let attributeString = NSMutableAttributedString(string:"welcome to china")
// 改变指定位置的字符串的文字 font
attributeString.addAttribute(NSFontAttributeName,
value: UIFont.systemFont(ofSize: 20),
range: NSMakeRange(0, 4))
// 设置指定位置的字体颜色
attributeString.addAttribute(NSForegroundColorAttributeName, value: UIColor.blue,
range: NSMakeRange(0, 3))
// 设置指定位置的文字背景颜色
attributeString.addAttribute(NSBackgroundColorAttributeName, value: UIColor.green,
range: NSMakeRange(3,3))
label.attributedText = attributeString
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
swift 实践- 03 -- UILabel的更多相关文章
- Swift - 通过叠加UILabel来实现混合的进度条
Swift - 通过叠加UILabel来实现混合的进度条 效果 源码 https://github.com/YouXianMing/Swift-Animations // // MixedColorP ...
- 使用Bootstrap 3开发响应式网站实践03,轮播下方的内容排版
通常把一些重要信息.需要重点标注的信息放在轮播的下方显示,这部分区域用到了大字体的标题.副标题以及段落文字等. <div class="row" id="bigCa ...
- iOS -Swift 3.0 -UILabel属性大全
昨天研究了一下苹果近两年新出的Swift语言,感觉学起来并不是很吃力,毕竟自己有过Objective-C的语言功底,所以各方面的属性控件还是一眼就可以认出的,只是Swift的写法与Objective- ...
- MatrixOne从入门到实践03——部署MatrixOne
MatrixOne从入门到实践--部署MatrixOne 前两章节我们简单介绍了MatrixOne和源码编译了MatrixOne.本章节将使用不同的部署方式,来部署MatrixOne的服务. 注意:不 ...
- Swift - 文本标签(UILabel)的用法
1,标签的创建 1 2 3 4 5 6 7 8 9 10 import UIKit class ViewController: UIViewController { override func ...
- swift 实践- 13 -- UIStepper
import UIKit class ViewController: UIViewController { var stepper: UIStepper! var label: UILabel! ov ...
- swift 实践- 08 -- UISegmentedControl
import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoa ...
- swift 实践- 02 -- 自定义cell 的简单使用
import UIKit class MyTableViewCell: UITableViewCell { var imageV: UIImageView? var titleLabel: UILab ...
- Swift 学习- 03 -- 基本运算符
// 运算符是检查,改变,合并值的特殊符号或短语, // swift 支持大部分标准的 C语言的运算符, 且改进许多特性来减少常规编码错误. /* 如: 赋值符 (=) 不返回值, 以防止把想要判断相 ...
随机推荐
- core.net 创建coreclass 项目出现一些问题
错误如下: Project CoreTest does not have a lock file. Please run "dotnet restore" to generate ...
- oracle 根据在线更新分区。
LOG_PURCHASEINFO 是没有分区之前的表,根据 LOG_PURCHASEINFO_P 分区好的表在线更新 LOG_PURCHASEINFO表,让他变成分区表.11g才可以使用list_ra ...
- 使用函数输出水仙花数 (void的用法)
6-11 使用函数输出水仙花数 (20 分) 水仙花数是指一个N位正整数(N≥3),它的每个位上的数字的N次幂之和等于它本身.例如:153=13+53+33. 本题要求编写两个函数, ...
- Python 爬虫四 基础案例-自动登陆github
GET&POST请求一般格式 爬取Github数据 GET&POST请求一般格式 很久之前在讲web框架的时候,曾经提到过一句话,在网络编程中“万物皆socket”.任何的网络通信归根 ...
- python 数据分析3
本节概要 pandas简介 安装 pip install pandas pandas的2个主要数据结构:DataFrame 和 Series Series series是一种类似于一维数组的对象,它由 ...
- 【blog】SpringBoot普通类中如何获取其他bean例如Service、Dao
自己写工具类 工具类 import org.springframework.beans.BeansException; import org.springframework.context.Appli ...
- 02、natapp的使用
使用方法 官网: https://natapp.cn 命令启动:natapp -authtoken=***************** 文档:https://natapp.cn/article/nat ...
- 前端html1.
HTML介绍 转载http://www.cnblogs.com/liwenzhou/p/7988087.html Web服务本质 import socket sk = socket.socket() ...
- McQueenRPC源码阅读
1.server 2.client 3.消息格式
- javascript面试--网络收集
史上最全的Javascript面试题总结(内附答案) - CSDN博客http://blog.csdn.net/u011277123/article/details/70208768 6.什么是未声明 ...