//
// 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 // 更新终点
}
}

使用贝赛尔曲线画扇形、圆形、弧线、多边形,实现App下载时的动画效果demo的更多相关文章

  1. Path画直线与弧线

    代码地址如下:http://www.demodashi.com/demo/14754.html 前言 之前讲过Paint和Canvas的基本使用,今天来介绍下Path的使用 涉及内容有: Path画直 ...

  2. 纯CSS3画出小黄人并实现动画效果

    前言 前两天我刚发布了一篇CSS3实现小黄人动画的博客,但是实现的CSS3动画是基于我在站酷网找到的一张小黄人的jpg格式图片,并自己用PS抠出需要实现动画的部分,最后才完成的动画效果.但是,其实我的 ...

  3. css画扇形按钮

    最近项目中需要制作一个扇形按钮,效果是这样的: 周围四个扇形,和中间的小圆,全是能点击的.这就需要画扇形.百度了一下,有很多文章讲了如何生成扇形,最后我借鉴了一个最简单的实现方式,使用css的clip ...

  4. canvas画扇形图(本文来自于http://jo2.org/html5-canvas-sector/)

    1.定义画扇形的构造函数: //扇形CanvasRenderingContext2D.prototype.sector = function (x, y, radius, sDeg, eDeg) {/ ...

  5. Python3 tkinter基础 Canvas create_rectangle 画虚边的矩形 create_oval 画椭圆形 圆形

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  6. 根据多个点使用canvas贝赛尔曲线画一条平滑的曲线

    众所周知想用canvas画一条曲线我们可以使用这些函数: 二次曲线:quadraticCurveTo(cp1x, cp1y, x, y) 贝塞尔曲线:bezierCurveTo(cp1x, cp1y, ...

  7. canvas画扇形、饼图

    画扇形的方法 方法一:起始角度是0,那么第一条线就是line(r,0),通过旋转扇形的角度,第二条线就是line(r,0) //圆弧 ctx.save(); ctx.translate(100, 10 ...

  8. Android自定义View 画弧形,文字,并增加动画效果

    一个简单的Android自定义View的demo,画弧形,文字,开启一个多线程更新ui界面,在子线程更新ui是不允许的,但是View提供了方法,让我们来了解下吧. 1.封装一个抽象的View类   B ...

  9. 纯css3圆形从中心向四周扩散动画效果

    查看效果:http://hovertree.com/texiao/css3/37/ 先来个简单的示例,例如: @keyframes hovertreemove{from {top:30px;}to { ...

随机推荐

  1. Json.Net 使用属性定义日期的序列化格式

    如果一个实体类里所有的时间即DateTime类型的字段,都处理成统一格式的话,可以使用如下方式: IsoDateTimeConverter timeFormat = new IsoDateTimeCo ...

  2. 安装linux操作系统--浪潮服务器

    一直都是在虚拟机上进行安装linux操作系统,在服务器上安装的很少,也没有碰到过没找到驱动的情况,例如什么raid卡驱动,网卡驱动等异常情况的发生. 这次安装了两台服务器,浪潮的提供的服务器,硬盘是两 ...

  3. C#缓存的一点想法及测试

    项目开发中,用到了缓存,其中的一个列表项,可能要多线程处理,就有了下面的想法,具体的问题在代码中有详细说明,见下文. static void Main(string[] args) { 测试缓存的想法 ...

  4. 对easyui datagrid组件的一个小改进

    #对easyui datagrid组件的一个小改进 ##问题 在实际项目中使用datagrid时,受版面限制,有时候表格不能太大,这时候表格里面的内容就不能完全显示,用户需要经常拖动调整列宽才能看完整 ...

  5. erlang observer工具

    1.服务器安装wxWidgets,之前需要装gtk+库 2.客户端安装otp_win64_17.5.exe 3.快捷方式点属性,在D:\erl6.4\bin\werl.exe后面加上参数 -setco ...

  6. 自建存储与使用微软Azure、七牛等第三方云存储综合考察分析

    http://www.cnblogs.com/sennly/p/4136734.html 各种云服务这两年炒的火热,加之可以降低成本,公司想先在部分业务上尝试使用下,刚好最近有个项目有大量小文件需要存 ...

  7. 20160512关于mac安装caffe的记录

    记得2015年在mac系统上安装过一次caffe,非常顺利,但是最近群里许多同学反映mac安装caffe出现了各种问题,同时我也在帮助别人安装caffe的时候也遇到了一些坑,不再像以前这么顺利了.估计 ...

  8. Android调用系统自带的文件管理器进行文件选择并读取

    先调用: intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("*/*"); //设置类型,我这里是任意类 ...

  9. JVM系列五:JVM监测&工具[整理中]

    前几篇篇文章介绍了介绍了JVM的参数设置并给出了一些生产环境的JVM参数配置参考方案.正如之前文章中提到的JVM参数的设置需要根据应用的特性来进行设置,每个参数的设置都需要对JVM进行长时间的监测,并 ...

  10. pd虚拟机死机怎么解决

    最近在mac上使用pd虚拟机装win使用,今天发现pd中的win7虚拟机死机了,无论怎么点都没用,通过点击操作-关闭也不行,重启电脑也不行,后来找到一种办法可以重启虚拟机. 1.先通过菜单中止虚拟机, ...