zoukankan      html  css  js  c++  java
  • 绘画画圆

    - (id)initWithFrame:(CGRect)frame

    {

        self = [super initWithFrame:frame];

        if (self) {

            self.frame = frame;

            _lineWidth = 3;

            self.progress = 0;

        }

        returnself;

    }

    - (void)updateProgress:(float)pro

    {

        self.progress = pro;

        [selfsetNeedsDisplay];

    //绘画

    - (void)drawRect:(CGRect)rect {

        

        CGRect allRect = self.frame;//自身大小

        CGContextRef context = UIGraphicsGetCurrentContext();//获取绘画上下文

        CGContextSetStrokeColorWithColor(context, [UIColorcolorWithHex:@"#0079ff"].CGColor);//设置绘画颜色

        float x = (allRect.size.width / 2);

        float y = (allRect.size.height / 2);//获取圆心点

        CGContextSetLineWidth(context, _lineWidth);//设置线条宽度

    //     CGContextSetLineCap(context, kCGLineCapRound);//设置线冒

        CGContextMoveToPoint(context, x, _lineWidth/2.0);// 把绘画的起始点移到园的顶部

                                         //圆心点 //半径   //开始角度     //结束角度 //顺时针

        CGContextAddArc(context, x, y, self.frame.size.width/2 - _lineWidth/2.0, -(M_PI*1/2), - M_PI* 1/2 + (2 * self.progress * M_PI), 0); ///绘画的坐标与数学的正坐标不一样,计算弧度的时候是顺时针为正弧度,逆时针是负弧度

        CGContextStrokePath(context);//完成行程路径开始绘画

    }

  • 相关阅读:
    解决Cannot change version of project facet Dynamic web module to 3.0
    mysql 存储过程
    查看建表语句
    mysql query cache 查询缓存
    数据库连接池
    JDBC Statement PrepareStatement
    mysql 改变表结构 alter
    maven 获取pom.xml的依赖---即仓库搜索服务
    windows常用快捷键
    oracle 的数据完整性
  • 原文地址:https://www.cnblogs.com/leevaboo/p/3230050.html
Copyright © 2011-2022 走看看