绘制矩形

作者: 开心就好2008 | 来源:发表于2017-12-09 16:48 被阅读0次

    -(void)drawRect:(CGRect)rect{

    CGContextRefcontext =UIGraphicsGetCurrentContext();

    CGRectframeSize =self.bounds;

    CGContextMoveToPoint(context,0,0);//起始点

    CGContextAddLineToPoint(context, frameSize.size.width/2+30,0);//上平行线

    CGContextAddLineToPoint(context, frameSize.size.width/2, frameSize.size.height);//右斜线

    CGContextAddLineToPoint(context,0, frameSize.size.height);//下平行线

    CGContextClosePath(context);//收拢, 做成直角梯形

    [[UIColorredColor]setFill];

    CGContextSetShadow(context,CGSizeMake(4,3),5);

    CGContextDrawPath(context,kCGPathFill);

    CGContextMoveToPoint(context, frameSize.size.width/2+30,0);//起始点

    CGContextAddLineToPoint(context, frameSize.size.width,0);//上平行线

    CGContextAddLineToPoint(context, frameSize.size.width, frameSize.size.height);//右斜线

    CGContextAddLineToPoint(context, frameSize.size.width/2, frameSize.size.height);//下平行线

    CGContextClosePath(context);//收拢, 做成直角梯形

    [[UIColorcyanColor]setFill];

    CGContextSetShadow(context,CGSizeMake(4,3),5);

    CGContextDrawPath(context,kCGPathFill);

    }

    相关文章

      网友评论

        本文标题:绘制矩形

        本文链接:https://www.haomeiwen.com/subject/gzyuixtx.html