Re: UI to allow user to scale and crop image within a circle
Re: UI to allow user to scale and crop image within a circle
- Subject: Re: UI to allow user to scale and crop image within a circle
- From: Charles Jenkins <email@hidden>
- Date: Tue, 23 Feb 2016 15:32:17 -0500
Jon:
Thanks for that advice. I’ll have a look!
Quincey:
I start with a screen in the storyboard and its default view I’ll call “superview.” Into the superview I toss a scrollview and a toolbar with Cancel and Crop buttons. I position them with autolayout and wire them up to my Swift view controller class.
In viewDidLoad(), I take an image previously selected by the user, create a UIImageView for it, then put that into the scrollview. The view controller instance sets itself to be the scrollview’s delegate, and when the scrollview asks, “what am I scrolling and sizing?” that UIImageView is what the call returns. When the user taps “Crop,” we notify the class that brought this view controller into existence, and it asks for the scaled and cropped portion of the image appearing in the scrollview. So far all this stuff seems to work perfectly.
The only thing I’m lacking is, I want to show a circle over the scrollview so that the user can see what portion of the image will be retained if we crop the image into a circle. The circle should aspect-fit over the scrollview’s viewport, but not be managed by the scrollview. The scrollview knows nothing about the circle. The circle’s just a layer hovering “above” the scrollview but not accepting touch events.
I’ve been trying to make the circle with an overlay UIImageView pinned so its frame is sized and positioned over the scrollview, but either (a) the overlay isn’t getting resized by autolayout, or (b) the circle artwork isn’t aspect-fitting inside the overlay view.
My approach may be completely wrong. This is the first time I’ve tried to inject an overlay view into the view hierarchy, so I’m probably doing it completely wrong or missing something very basic.
--
Charles
On February 23, 2016 at 12:51:59, Quincey Morris (email@hidden) wrote:
On Feb 23, 2016, at 04:28 , Charles Jenkins <email@hidden> wrote:
My scrollview containing an imageview seems to work just fine: I can scale and crop an image with no problem. But I’m having difficulty getting the desired “crop circle” to hover over the scrollview properly.
It’s not clear to me exactly what strategy you’re attempting. I can see at least 4 possibilities:
1. The scroll view is itself a child (or a sibling) of a view that represents the circle.
2. The circle view is a child of the scroll view, but not of its content view.
3. The circle view is a child of the scroll view’s content view, but is a different view from the image view.
4. The circle view and image view are the same custom view, with gestures to pan and scale cause the image to move/resize relative to the circle.
So I’m not sure whether scrolling the scroll view is the UI for positioning the image relative to the circle, or is the UI for scrolling. Similarly, I’m not sure if scaling from the scroll view is the UI for scaling the image relative to the circle, or is just the UI for zooming in.
I’m inclined to think that using the scroll view to position the image relative to the circle isn’t semantically correct, but perhaps that’s not what you’re doing anyway.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden