Quartz2D - 基本图形绘制(形状)

来源:互联网 发布:字幕视频合成软件 编辑:程序博客网 时间:2024/05/21 17:17

1.空心圆圈


    // 创建    UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(20, 20, 200, 200) cornerRadius:100];        // 设置属性    path.lineWidth = 5;    path.lineCapStyle = kCGLineCapRound;    path.lineJoinStyle = kCGLineJoinRound;    [[UIColor redColor] set];        // 绘制    [path stroke];

2.实心圆

    // 创建    UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(20, 20, 200, 200) cornerRadius:100];        // 设置属性    path.lineWidth = 5;    path.lineCapStyle = kCGLineCapRound;    path.lineJoinStyle = kCGLineJoinRound;    [[UIColor redColor] set];        // 填充(必须是一个完整的封闭路径)    [path fill];

3.圆弧


    /*     center:圆心     startAngle: 弧度     clockwise:YES顺时针/NO逆时针     */    UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(150, 150) radius:100 startAngle:0 endAngle:-M_PI_2 clockwise:NO];        path.lineWidth = 5;    [[UIColor orangeColor] set];        [path stroke];

4.扇形


    // 扇形    CGPoint center = CGPointMake(150, 150);    UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:center radius:100 startAngle:0 endAngle:-M_PI_2 clockwise:NO];        // 添加一根线到圆心    [path addLineToPoint:center];    // 关闭路径(从路径的终点到起点)    [path closePath];        path.lineWidth = 5;    [[UIColor redColor] set];        [path fill];

0 0
原创粉丝点击