给定一个CGMutablePathRef我如何在其中绘制UIImage?我知道您可以按照以下方式绘制它:
UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[scaledImage drawAtPoint:CGPointMake(0, 0)];
CGContextRestoreGState(context);
但是我不确定是否有路径(圆角矩形)如何在其中添加图像?
最佳答案
当您说“在CGMutablePath内绘制”时,我必须假设您的意思是“剪辑到 CGMutablePath。”在这种情况下,您只需要将路径添加到当前上下文(CGContextAddPath()
或任何路径构建功能,例如CGContextAddLineToPoint()
),然后调用CGContextClip()
即可。然后,您可以使用drawAtPoint:
或CGContextDrawImage()
之类的内容在上下文中绘制图像。
关于iphone - 在CGMutablePath中绘制UIImage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14249304/