开发者

crop image via drawing circle in imageview

i want to crop image via drawing circle using touchMoved event. so how can i find the circle point in CGRect .

i have to just pass that cgrect开发者_如何学JAVA to cropping function.

Pls Help me for drawing the circle on image and find the CGRect

Thanks


I'm not sure that I completely understand your question. I will make some assumptions:

I assume you want to display a circular region of an image, with the image cropped to only display its content within that circle; and

I assume you will be moving this circle around as the user moves his/her finger.

I will assume the non-cropped area is a solid color.

For this case, I would recommend creating a transparent png image file with a circle of transparency, and the solid background color everywhere else. You can put this in a drag-and-drop-able UIView subclass, and when the user moves his/her finger around, it will appear as if the image is being cropped in a circle that moves with their finger.

Here's how to make a UIView subclass work with drag-and-drop:

http://bynomial.com/blog/?p=77

If you need more sophisticated behavior, such as a non-solid-color background, then you could consider using an image mask with your view's CALayer property. This would be more work, because you'd have to modify the mask every time the user moved their finger. Another option would be to set the CALayer to have rounded corners (the cornerRadius property), set clipsToBounds=YES, and then move that around appropriately when the user moves their finger.

Reference for some CALayer properties, to get a sense of the cornerRadius approach (set the cornerRadius = half the width of the view, and it will be a circle):

http://bynomial.com/blog/?p=52

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜