I am trying to create a user interface for cropping images on iphone OS and suspect that I am going to do something difficult. My goal is pretty much what the Tapbots duo did with Pastebot. In this application, they reduce the original image, but provide a movable and resizable crop, and the image you crop has a scalable scroll; When resizing or moving the main image, the crop view is set accordingly.
I mocked the complex image, which will give an idea of โโthe design that I need, as well as how I now establish my hierarchy of representations.
alt text http://grab.by/3TN4
The approach I started working with is the following: a UIImageView with a cropping image is in a scrollview, a simple UIView with black filling and a suitable transparency / alpha setting are added before the image is presented. Then I use a custom UIView that is native to a higher level scrollview that implements the drawRect method: and for the most part calls CGImageCreateWithImageInRect to get the part of the bitmap that matches the position of the crop view, and draws it to CGContext.
in the viewcontroller, I use the UIScrollViewDelegate methods to track the scroll and pass these changes to the custom UIView trim, so it synchronizes with the contentOffset scroll. It finally works. But I try to maintain synchronization, since the scrollview zoomScale changes are when I decided that I should ask for help.
Look for suggestions or recommendations. My initial approach just seems more work than required.
Can this be done with a mask layer in ImageView? And if so, how do I set up tracking to move and resize the rectangle? My experience with layers is not zero, but so far very limited.
source
share