iPhone 剪辑图像与路径
我想用路径剪辑图像。在《Programming with Quartz》一书中,有一个关于如何绘制由矩形路径裁剪的圆的示例(第 37 页),还有一章关于使用现有图像作为模板的图像遮罩(第 10 章)。但我仍然不确定如何使用路径剪辑现有图像。有没有例子或指针?
I would like to clip an image with path. In the book Programming with Quartz there is an example on how to draw a circle clipped by a rectangular path (p.37), and there is also a chapter on image masking with existing image as stencil (Ch.10). But I'm still not sure about how to clip an existing image using path. Is there any example or pointer?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个应该有效的示例,它将剪切区域设置为路径(在我的例子中,该路径是椭圆形,您可以使用矩形)。然后绘制将被剪切的图像。在我的例子中,drawRect: 方法是绘制 UIView 上下文的方法。
Here is a sample that should work, it sets the clipping area as a path(this path in my case is an elipse, you could use a rect). Then the image that will be clipped is drawn. Method drawRect: is the one that draws the UIView's context in my case.