iOS开发 贝塞尔曲线

参考文章 https://www.jianshu.com/p/6c9aa9c5dd68

作为一个开发者,有一个学习的氛围跟一个交流圈子特别重要,这是一个我的iOS交流群:812157648,不管你是小白还是大牛欢迎入驻 ,分享BAT,阿里面试题、面试经验,讨论技术, 大家一起交流学习成长!

一、画线

画线效果

-(void)drawRect:(CGRect)rect{
    UIBezierPath *path = [UIBezierPath bezierPath];
    [path moveToPoint:CGPointMake(0, 0)]; //设置起点
    [path addLineToPoint:CGPointMake(50, 100)];
    [path addLineToPoint:CGPointMake(150, 50)];
    [path addLineToPoint:CGPointMake(300, 300)];
    
    path.lineCapStyle = kCGLineCapRound;//终点类型
    path.lineJoinStyle = kCGLineJoinRound;//交叉点类型
    path.lineWidth = 10.0;
    
//    UIColor *fillColor = [UIColor orangeColor];
//    [fillColor set];
//    [path fill]; //颜色填充
    
    UIColor *redColor = [UIColor redColor];
    [redColor set];
   [path stroke];//划线
}

二、矩形

画矩形

-(void)drawRect:(CGRect)rect{
    
    UIBezierPath *path = [UIBezierPath bezierPathWithRect:CGRectMake(50, 50, 200, 200)];
    path.lineWidth =5;
    UIColor *strokeColor = [UIColor orangeColor];
    [strokeColor set];
    [path stroke];
 
}

三、椭圆、圆

椭圆、圆

#pragma mark -绘制圆圈、椭圆
-(void)drawRect:(CGRect)rect{
    UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(100, 50, 200, 100)];
        
        path.lineWidth =3.0;

        UIColor *strokeColor = [UIColor orangeColor];
        [strokeColor set];
        
        [path stroke];
}

四、圆角矩形

圆角矩形

#pragma mark -圆角矩形
-(void)drawRect:(CGRect)rect{

    UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(100, 50, 150, 150) cornerRadius:6];

      path.lineWidth =2;
      
      UIColor *fillcolor = [UIColor orangeColor];
      [fillcolor set];
      
      [path stroke];
}

五、矩形的某个角为圆角

矩形的某个角为圆角

#pragma mark -矩形的某个角为圆角
-(void)drawRect:(CGRect)rect{
    UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(100, 80, 150, 150) byRoundingCorners:UIRectCornerBottomRight cornerRadii:CGSizeMake(20, 20)];
    
    path.lineWidth =2;
    
    UIColor *color = [UIColor orangeColor];
    [color set];
    
    [path stroke];
}

原文作者:喜剧收尾_XWX
原文地址:https://www.jianshu.com/p/2fca9a997d3a

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值