/**
* 图片裁剪
*
* 先画一个圆,让图片显示在圆的内部,超出的部分不显示。
*/
- (void)drawRect:(CGRect)rect
{
// 画圆
CGContextRef ref = UIGraphicsGetCurrentContext();
// CGContextAddArc(ref, 100, 100, self.radius, 0, 2*M_PI, 0);
CGContextAddEllipseInRect(ref, CGRectMake(10.0,20.0, 150.0,150.0));
//指定上下文中可以显示内容的范围就是圆的范
CGContextClip(ref);
UIImage *image = [UIImage imageNamed:@"C128E3B3-6631-4CEF-BD31-423F12EDBCAF"];
[image drawAtPoint:CGPointMake(0.0,20.0)];
}
/**
* 三角形
*
* @param rect <#rect description#>
*/
- (void)drawRect:(CGRect)rect
{
CGContextRef ctx =UIGraphicsGetCurrentContext();
//三个点确定一个三角形
CGContextMoveToPoint(ctx,30, 30);
CGContextAddLineToPoint(ctx,30, 150);
CGContextAddLineToPoint(ctx,150, 150);
CGContextClosePath(ctx);
CGContextClip(ctx);
UIImage *image = [UIImageimageNamed:@"C128E3B3-6631-4CEF-BD31-423F12EDBCAF"];
[image drawAtPoint:CGPointMake(0.0,20.0)];
}