欢迎来到Introzo百科
Introzo百科
使用贝赛尔曲线画扇形、圆形、弧线、多边形,实现App下载时的动画效果demo
-->
//
// MyView.swift
// TestUIBezierPath
//
// Created by iCodeWoods on 16/5/8.
// Copyright © 2016年 iCodeWoods. All rights reserved.
// import Foundation
import UIKit class MyView: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = UIColor.grayColor()
} required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
} // // 五边形
// override func drawRect(rect: CGRect) {
// let color = UIColor.redColor()
// color.set() // 设置线条颜色
//
// let aPath = UIBezierPath()
//
// aPath.lineWidth = 5.0 // 线条宽度
// aPath.lineCapStyle = .Round // 线条拐角
// aPath.lineJoinStyle = .Round // 终点处理
//
// // Set the starting point of the shape.
// aPath.moveToPoint(CGPointMake(100, 10))
//
// // Draw the lines
// aPath.addLineToPoint(CGPointMake(200, 50))
// aPath.addLineToPoint(CGPointMake(160, 150))
// aPath.addLineToPoint(CGPointMake(40, 140))
// aPath.addLineToPoint(CGPointMake(10, 60))
// aPath.closePath() // 最后一条线通过调用closePath方法得到
//
//// aPath.stroke() // Draws line 根据坐标点连线,不填充
// aPath.fill() // Draws line 根据坐标点连线,填充
// } // // 矩形
// override func drawRect(rect: CGRect) {
// let color = UIColor.redColor()
// color.set() // 设置线条颜色
//
// let aPath = UIBezierPath(rect: CGRectMake(40, 40, 100, 50)) // 长方形
//// let aPath = UIBezierPath(rect: CGRectMake(40, 40, 100, 100)) // 正方形
//
// aPath.lineWidth = 5.0 // 线条宽度
// aPath.lineCapStyle = .Round // 线条拐角
// aPath.lineJoinStyle = .Round // 终点处理
//
// aPath.stroke() // Draws line 根据坐标点连线,不填充
//// aPath.fill() // Draws line 根据坐标点连线,填充
// } // // 圆、椭圆
// override func drawRect(rect: CGRect) {
// let color = UIColor.redColor()
// color.set() // 设置线条颜色
//
// // 根据传人的矩形画出内切圆/椭圆
//// let aPath = UIBezierPath(ovalInRect: CGRectMake(40, 40, 100, 100)) // 如果传入的是正方形,画出的就是内切圆
// let aPath = UIBezierPath(ovalInRect: CGRectMake(40, 40, 100, 160)) // 如果传入的是长方形,画出的就是内切椭圆
//
// aPath.lineWidth = 5.0 // 线条宽度
//
//// aPath.stroke() // Draws line 根据坐标点连线,不填充
// aPath.fill() // Draws line 根据坐标点连线,填充
// } //// 弧线
// override func drawRect(rect: CGRect) {
// let color = UIColor.redColor()
// color.set() // 设置线条颜色
//
// let aPath = UIBezierPath(arcCenter: CGPointMake(150, 150), radius: 75, startAngle: 0, endAngle: (CGFloat)(90*M_PI/180), clockwise: true)
//
// aPath.lineWidth = 5.0 // 线条宽度
//
//// aPath.stroke() // Draws line 根据坐标点连线,不填充
// aPath.fill() // Draws line 根据坐标点连线,填充
// } // // 扇形
// override func drawRect(rect: CGRect) {
// let color = UIColor.redColor()
// color.set() // 设置线条颜色
//
// let aPath = UIBezierPath(arcCenter: CGPointMake(150, 150), radius: 75, startAngle: 0, endAngle: (CGFloat)(90*M_PI/180), clockwise: true)
// aPath.addLineToPoint(CGPointMake(150, 150))
// aPath.closePath()
// aPath.lineWidth = 5.0 // 线条宽度
//
// // aPath.stroke() // Draws line 根据坐标点连线,不填充
// aPath.fill() // Draws line 根据坐标点连线,填充
// } // 实现 App 下载时的效果
var beginAngle = M_PI*3/2 // 起点
var finishAngle = M_PI*3/2+M_PI*2/20 // 终点 override func drawRect(rect: CGRect) {
let color = UIColor.whiteColor()
color.set() // 设置线条颜色 let aPath = UIBezierPath(arcCenter: CGPointMake(150, 150), radius: 75, startAngle: (CGFloat)(beginAngle), endAngle: (CGFloat)(finishAngle), clockwise: true)
aPath.addLineToPoint(CGPointMake(150, 150))
aPath.closePath()
aPath.lineWidth = 5.0 // 线条宽度
// aPath.fill() // Draws line 根据坐标点连线,填充
aPath.fillWithBlendMode(.Normal, alpha: 0.5) finishAngle += M_PI/20 // 更新终点
}
} -->
// MyView.swift
// TestUIBezierPath
//
// Created by iCodeWoods on 16/5/8.
// Copyright © 2016年 iCodeWoods. All rights reserved.
// import Foundation
import UIKit class MyView: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = UIColor.grayColor()
} required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
} // // 五边形
// override func drawRect(rect: CGRect) {
// let color = UIColor.redColor()
// color.set() // 设置线条颜色
//
// let aPath = UIBezierPath()
//
// aPath.lineWidth = 5.0 // 线条宽度
// aPath.lineCapStyle = .Round // 线条拐角
// aPath.lineJoinStyle = .Round // 终点处理
//
// // Set the starting point of the shape.
// aPath.moveToPoint(CGPointMake(100, 10))
//
// // Draw the lines
// aPath.addLineToPoint(CGPointMake(200, 50))
// aPath.addLineToPoint(CGPointMake(160, 150))
// aPath.addLineToPoint(CGPointMake(40, 140))
// aPath.addLineToPoint(CGPointMake(10, 60))
// aPath.closePath() // 最后一条线通过调用closePath方法得到
//
//// aPath.stroke() // Draws line 根据坐标点连线,不填充
// aPath.fill() // Draws line 根据坐标点连线,填充
// } // // 矩形
// override func drawRect(rect: CGRect) {
// let color = UIColor.redColor()
// color.set() // 设置线条颜色
//
// let aPath = UIBezierPath(rect: CGRectMake(40, 40, 100, 50)) // 长方形
//// let aPath = UIBezierPath(rect: CGRectMake(40, 40, 100, 100)) // 正方形
//
// aPath.lineWidth = 5.0 // 线条宽度
// aPath.lineCapStyle = .Round // 线条拐角
// aPath.lineJoinStyle = .Round // 终点处理
//
// aPath.stroke() // Draws line 根据坐标点连线,不填充
//// aPath.fill() // Draws line 根据坐标点连线,填充
// } // // 圆、椭圆
// override func drawRect(rect: CGRect) {
// let color = UIColor.redColor()
// color.set() // 设置线条颜色
//
// // 根据传人的矩形画出内切圆/椭圆
//// let aPath = UIBezierPath(ovalInRect: CGRectMake(40, 40, 100, 100)) // 如果传入的是正方形,画出的就是内切圆
// let aPath = UIBezierPath(ovalInRect: CGRectMake(40, 40, 100, 160)) // 如果传入的是长方形,画出的就是内切椭圆
//
// aPath.lineWidth = 5.0 // 线条宽度
//
//// aPath.stroke() // Draws line 根据坐标点连线,不填充
// aPath.fill() // Draws line 根据坐标点连线,填充
// } //// 弧线
// override func drawRect(rect: CGRect) {
// let color = UIColor.redColor()
// color.set() // 设置线条颜色
//
// let aPath = UIBezierPath(arcCenter: CGPointMake(150, 150), radius: 75, startAngle: 0, endAngle: (CGFloat)(90*M_PI/180), clockwise: true)
//
// aPath.lineWidth = 5.0 // 线条宽度
//
//// aPath.stroke() // Draws line 根据坐标点连线,不填充
// aPath.fill() // Draws line 根据坐标点连线,填充
// } // // 扇形
// override func drawRect(rect: CGRect) {
// let color = UIColor.redColor()
// color.set() // 设置线条颜色
//
// let aPath = UIBezierPath(arcCenter: CGPointMake(150, 150), radius: 75, startAngle: 0, endAngle: (CGFloat)(90*M_PI/180), clockwise: true)
// aPath.addLineToPoint(CGPointMake(150, 150))
// aPath.closePath()
// aPath.lineWidth = 5.0 // 线条宽度
//
// // aPath.stroke() // Draws line 根据坐标点连线,不填充
// aPath.fill() // Draws line 根据坐标点连线,填充
// } // 实现 App 下载时的效果
var beginAngle = M_PI*3/2 // 起点
var finishAngle = M_PI*3/2+M_PI*2/20 // 终点 override func drawRect(rect: CGRect) {
let color = UIColor.whiteColor()
color.set() // 设置线条颜色 let aPath = UIBezierPath(arcCenter: CGPointMake(150, 150), radius: 75, startAngle: (CGFloat)(beginAngle), endAngle: (CGFloat)(finishAngle), clockwise: true)
aPath.addLineToPoint(CGPointMake(150, 150))
aPath.closePath()
aPath.lineWidth = 5.0 // 线条宽度
// aPath.fill() // Draws line 根据坐标点连线,填充
aPath.fillWithBlendMode(.Normal, alpha: 0.5) finishAngle += M_PI/20 // 更新终点
}
} -->
相关文章
- 10-06 华为p50功耗排行查看教程
- 10-06 Huawei Share连接电脑教程
- 10-06 华为鸿蒙系统支持的手机型号列表
- 10-06 Python Joblib库使用方法总结
- 10-06 Python标准类库
- 10-06 Java Maven 设置配置参考
- 10-05 戈多的场景树
- 10-05 戈多动画
- 10-05 在 Godot 中设计标题画面
- 10-05 信息搜索和可视化
- 10-05 设计流程与任务分析
- 10-05 颤动警报对话框
- 10-05 PostgreSQL远程连接配置管理/账号密码分配
- 10-05 Windows server 创建FTP 包括ft
- 10-05 Mongodb副本集加分片集群安全认证使用账号密码
- 10-05 浅谈ubuntu中执行.sh文件的几种方式的区别
- 10-05 Linux性能优化的实用思路和技巧(linux性能
- 10-05 如何轻松安装Linux系统显卡驱动(Linux安装
- 10-05 win10动态锁设置教程
- 10-05 win10关闭Win10右下角提示的教程
- 最近发表