Re: Programmatically pinch a UIView
Re: Programmatically pinch a UIView
- Subject: Re: Programmatically pinch a UIView
- From: Quincey Morris <email@hidden>
- Date: Wed, 11 May 2016 14:08:52 -0700
- Feedback-id: 167118m:167118agrif8a:167118stZoP8mteB:SMTPCORP
On May 11, 2016, at 13:56 , Carl Hoefs <email@hidden> wrote:
>
> I just tried UIScrollView & -setZoomScale:. No effect.
I think you’re flailing now. ;)
> I was hoping there was a way to initially programmatically pinch the view down by 10%, so the view's frame isn't reduced as well
You can’t make a view smaller without making it … smaller. Perhaps you’re not distinguishing the frame from the bounds? If you apply a 10% reduction to a 100 x 100 view via a transform, its frame will be 90 x 90, but its bounds will still be 100 x 100.
> Would it help if I changed my UIView to be a UIScrollView instead?
Well, you wouldn’t change your custom UIView to *be* a UIScrollView, but you might place your custom UIView *inside* a UIScrollView. Setting the zoomScale on a scroll view changes the transform on the content subviews, not on the scroll view itself. But wouldn’t you have a zoomable custom view inside a scroll view anyway? How else do you plan for the user to pan around when it’s zoomed in?
> I was hoping there was a way to initially programmatically pinch the view down by 10%
You could, I suppose, scale your content drawing, rather than scaling the view. In that case, you’d need to put the pinch gesture recognizer on your view, save the calculated scale factor every time the recognizer changes state, and redraw your view in drawRect: using the saved scale. But that’s the functionality that UIScrollView is generally designed to provide for you.
_______________________________________________
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