//
// 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. 移动端的日期插件 mobiscroll 2.14.4 破解版

    官方报价695美元 http://mobiscroll.com/pricing 这个 mobiscroll 2.14.4 破解版 包括datetime和calendar组件,包括mobiscroll和 ...

  2. Typecho集成ueditor笔记

    前言:萝卜青菜各有所爱,因为个人需求所以需要在博客中集成ueditor,并非是我不喜欢md语法 其实本篇的笔记的书写最早也是在本地的md编辑器上完成的 1. 首先下载ueditor编辑器,然后重命名文 ...

  3. ios自定义View自动布局时计算大小

    https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/Impleme ...

  4. 配置使VirtualBox下的linux可以宿主机互访并上网

    1. 设置VirtualBox,选择桥接网卡 2. 配置linux的ifcfg-eth0 配置完成后,用service network restart重启网络. 3. 然后查后路由配置是否正确 如果没 ...

  5. php基础知识(3)(文件加载include)

    文件加载 综述: 有4个文件加载的语法形式(注意,不是函数): include,  include_once,  require, require_once; 他们的本质是一样的,都是用于加载/引入/ ...

  6. HTML5每日一练之figure新标签的应用

    igure元素是一种元素的组合,可带有标题(可选).figure标签用来表示网页上一块独立的内容,将其从网页上移除后不会对网页上的其他内容产生影响.figure所表示的内容可以是图片.统计图或代码示例 ...

  7. C语言中返回字符串函数的四种实现方法 2015-05-17 15:00 23人阅读 评论(0) 收藏

    C语言中返回字符串函数的四种实现方法 分类: UNIX/LINUX C/C++ 2010-12-29 02:54 11954人阅读 评论(1) 收藏 举报 语言func存储 有四种方式: 1.使用堆空 ...

  8. iOS开发中的Get请求和POST请求

    //Get请求一般为不涉及到用户的账号密码的网络请求,其中Get请求是等请求内容回来之后,才可以进行下一步的操作 - (void)requestWithGet{ //Get请求: //1.设置请求路径 ...

  9. JDBC 与 ODBC 区别

    一. 二.

  10. oracle创建自增长列

    --创建一个新表 /*create table students(stu_id number,stu_name varchar2(20),stu_email varchar2(40),primary ...