0

我正在使用绘制图像的三角形部分

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

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

4

0 回答 0