-(void)drawRect:(CGRect)rect{
//获取上下文
CGContextRef ctx = UIGraphicsGetCurrentContext();
//开始绘画
CGContextBeginPath(ctx);
//起始点
CGContextMoveToPoint (ctx, CGRectGetMaxX(rect), CGRectGetMaxY(rect));
//连接线到点
CGContextAddLineToPoint(ctx, CGRectGetMinX(rect), CGRectGetMidY(rect));
//连接线到点
CGContextAddLineToPoint(ctx, CGRectGetMaxX(rect), CGRectGetMinY(rect));
//结束绘画路径
CGContextClosePath(ctx);
//设置线条内部的填充色
CGContextSetRGBFillColor(ctx, 1, 1, 1, 1);
CGContextFillPath(ctx);
}
iOS绘制图形(三角形)
最新推荐文章于 2024-04-11 01:40:12 发布