Xcode9学习笔记84
来源:互联网 发布:mac 无损调整分区大小 编辑:程序博客网 时间:2024/04/29 13:19
import UIKitclass QuartzView: UIView { // Only override draw() if you perform custom drawing. // An empty implementation adversely affects performance during animation. override func draw(_ rect: CGRect) { // Drawing code let context = UIGraphicsGetCurrentContext() context?.setFillColor(red: 1.0, green: 0.0, blue: 1.0, alpha: 1.0) context?.fill(rect) context?.setStrokeColor(red: 0, green: 0, blue: 0, alpha: 1.0) let rect2 = CGRect(x: 40, y: 80, width: 240, height: 40) context?.addRect(rect2) context?.setLineWidth(5.0) context?.strokePath() let font = UIFont.boldSystemFont(ofSize: 32) let text:NSString = "Hello" let rect3 = CGRect(x: 50, y: 80, width: 80, height: 30) text.draw(in: rect3, withAttributes: [NSAttributedStringKey.font : font]) context?.setLineWidth(5.0) context?.setLineCap(CGLineCap.round) context?.setStrokeColor(red: 1, green: 1, blue: 1, alpha: 1) let points = [CGPoint(x:40, y:200), CGPoint(x:40, y:300), CGPoint(x:280, y:300), CGPoint(x:40, y:200)] context?.addLines(between: points) context?.strokePath() }}
override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. let rect = self.view.bounds//获得当前根视图的显示区域 let view = QuartzView() view.frame = rect self.view.addSubview(view) }
阅读全文
0 0
- Xcode9学习笔记84
- Xcode9学习笔记1
- Xcode9学习笔记2
- Xcode9学习笔记3
- Xcode9学习笔记4
- Xcode9学习笔记5
- Xcode9学习笔记6
- Xcode9学习笔记7
- Xcode9学习笔记8
- Xcode9学习笔记9
- Xcode9学习笔记10
- Xcode9学习笔记11
- Xcode9学习笔记12
- Xcode9学习笔记13
- Xcode9学习笔记14
- Xcode9学习笔记15
- Xcode9学习笔记16
- Xcode9学习笔记17
- tochar和todate总结
- 欢迎使用CSDN-markdown编辑器
- PHP打印调用stack到网页
- 文章标题
- YII2增删改查
- Xcode9学习笔记84
- netty编解码之java原生序列化
- 【11-Redis复制】
- js模板引擎art-template.js使用方法
- amaze-vue —— 基于Vue.js和amazeui样式的响应式UI框架
- c# 处理文件流
- trunc函数
- 《七点三刻》027期 中考取消?/马云回应乌镇饭局/上调最低工资/比特币期货来了
- oracle next_day