zoukankan      html  css  js  c++  java
  • 贝塞尔曲线

    第一种加载方法

    - (void)drawRect:(CGRect)rect {
        UIBezierPath *backPath = [UIBezierPath bezierPath];
        [backPath moveToPoint:CGPointMake(0, 0)];
        [backPath addLineToPoint:CGPointMake(0, rect.size.height)];
        [backPath addLineToPoint:CGPointMake(rect.size.width, rect.size.height)];
        [backPath addLineToPoint:CGPointMake(rect.size.width, 0)];
        [backPath closePath];
        [self.superview.backgroundColor set];
        [backPath fill];
        
        
        CGFloat width = MIN(CGRectGetWidth(rect), CGRectGetHeight(rect));
        CGFloat lineW = 3 / [UIScreen mainScreen].scale;
        
        UIBezierPath *backProPath = [UIBezierPath bezierPath];
        [backProPath addArcWithCenter:CGPointMake(width / 2., width / 2.) radius:width / 2. - 10 startAngle:0 endAngle:M_PI * 2 clockwise:true];
        backProPath.lineWidth = lineW;
        [[UIColor grayColor] set];
        [backProPath stroke];
        
        
        UIBezierPath *progressPath = [UIBezierPath bezierPath];
        [progressPath addArcWithCenter:CGPointMake(width / 2., width / 2.) radius:width / 2. - 10 startAngle:0 endAngle:M_PI_4 clockwise:true];
        progressPath.lineWidth = lineW;
        [[UIColor redColor] set];
        [progressPath stroke];
    }
    

    第二种加载方法

    - (void)drawRect:(CGRect)rect {
        UIBezierPath *tempPath = [UIBezierPath bezierPathWithRect:rect];
        [self.superview.backgroundColor set];
        [tempPath fill];
        
        
        CGFloat width = MIN(CGRectGetWidth(rect), CGRectGetHeight(rect));
        
        
        CAShapeLayer *backLayer = [CAShapeLayer layer];
        
        backLayer.lineWidth = 3 / [UIScreen mainScreen].scale;
        backLayer.strokeColor = [UIColor cyanColor].CGColor;
        backLayer.fillColor = [UIColor redColor].CGColor;
        
        [self.layer addSublayer:backLayer];
        
        UIBezierPath *backPath = [UIBezierPath bezierPath];
        [backPath addArcWithCenter:CGPointMake(width / 2., width / 2.) radius:width / 2. - 3 startAngle:0 endAngle:M_PI_4 clockwise:true];
        
        
        backLayer.path = backPath.CGPath;
    }
    
  • 相关阅读:
    Spring入门之通过注解 处理 数据库事务
    Spring 入门之-dao使用jdbcTemplate(注入过程)
    spring入门之JdbcTemplate 操作crud
    npm 包 升降版本
    vue-cli初始化一个项目
    <meta http-equiv="refresh" content="0; url=">
    vue-router的两种模式的区别
    Webstorm 的 Tab 键怎样调整缩进值? 调节成缩进成2个空格或者4个空格
    去抖函数 节流函数
    创建一个vue项目,vue-cli,webpack
  • 原文地址:https://www.cnblogs.com/shenhongbang/p/4776667.html
Copyright © 2011-2022 走看看