在iPhone中以三角形绘制整个图像?

时间:2012-08-16 09:31:27

标签: iphone core-graphics

我正在使用

绘制图像的三角形部分
    UIImage *image = [UIImage imageNamed:@"sampleImage.png"];
    CGMutablePathRef path = CGPathCreateMutable(); 
    CGPathMoveToPoint(path,NULL,10.0f, 200.0f); 
    CGPathAddLineToPoint(path,NULL,200.0f,10.0f); 
    CGPathAddLineToPoint(path,NULL,200.0f,200.0f);
    CGPathAddLineToPoint(path,NULL,200.0f,200.0f);
    CGPathCloseSubpath(path); 
    CGContextRef ctx = UIGraphicsGetCurrentContext(); 
    CGContextSetFillColorWithColor(ctx, [UIColor blueColor].CGColor); 
    CGContextAddPath(ctx, path); 
    CGAffineTransform flipVertical = CGAffineTransformMake(1, 0, 0, -1, 0, image.size.height);
    CGContextConcatCTM(ctx, flipVertical); 
    CGContextClip(ctx);
    CGContextDrawImage(ctx, CGRectMake(10, 10.0f, 200.0f, 200.0f), image.CGImage);
    CGContextFillPath(ctx); 

但我需要将整个图像映射到三角形区域。是否有可能使用核心图形来实现这一目标?

0 个答案:

没有答案