绘制矩形

-(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);

}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容