//
// 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. bzoj1036 树的统计Count

    第一次写链剖,于是挑了个简单的裸题写. 以下几点要注意: 1.链剖中的height是从根到该店经过的轻边个数 2.分清num与sum..... #include<cstdio> #incl ...

  2. php获取上传多个文件缺失

    我们的一个页面编辑发布后台出现了图片无法上传保存的情况,经过调试对比发现,原来是file表单数量过多导致,减少file表单的数量即可上传成功.为了满足需求不减少file表单数并保证上传成功,于是更改了 ...

  3. 【LeetCode】38 - Count and Say

    The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...

  4. C语言实现strcpy

    strcpy.h: #ifndef STRCPY_H #define STRCPY_H #include <stdio.h> char *cat_strcpy(char *dst, con ...

  5. leetcode–jump game II

    1.题目描述 Given an array of non-negative integers, you are initially positioned at the first index of t ...

  6. 《Java数据结构与算法》笔记-CH4-4循环队列

    /** * 循环队列 */ class Queue { private int maxSize; private long[] queue; private int front; private in ...

  7. HDU ACM 3177 Crixalis's Equipment

    Crixalis's Equipment Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Oth ...

  8. python添加windows域验证

    1.安装python-ldap https://pypi.python.org/pypi/python-ldap/ 在 Ubuntu/Debian 下安装 python-ldap 模块: $ sudo ...

  9. jszs 对象引用

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  10. 轻松学习Linux之自动执行任务

    在 Linux 中,任务可以被配置在指定的时间段.指定的日期.或系统平均载量低于指定的数量时自动运行,系统管理员可使用自动化的任务来执行定期备份.监控系统.运行定制脚本等,往往初学者都是win用户,习 ...