ios - Xcode UIScrollView zoom same as MKMapView zoom (no effect on subview) -
i want add zoom effect on uiscrollview
. have achieved uiscrollview
delegate methods.
(uiview *)viewforzoominginscrollview:(uiscrollview *)scrollview
.
now want add effect mkmapview
having in it, if zoom-in or zoom-out mkmapview
place marker of map remains @ same place , same size. how can can achieve same effect uiscrollview
zoom effect.
my initial guess cgaffinetransform
. question when , how?
thanks, jay stepin.
if understand correctly, want able zoom scroll view in , out while visual objects on remain "anchored" locations. i'd suggest use uiscrollview
's zoomscale
property tells multiplier should apply scroll view's content positions.
say, have object (uiimage
, example) it's center
@ x = 100.0
, y = 100.0
, zoomscale = 1.0
. define couple of constants/variables store coordinates somewhere (let's call them initialx
, initialy
, example). track zoomscale
value in uiscrollviewdelegate
protocol's - scrollviewdidzoom:
method , multiply initial (not current!) coordinates zoomscale
's value.
e.g. (adjust code):
#pragma mark - uiscrollviewdelegate - (void)scrollviewdidzoom:(uiscrollview *)scrollview { cgfloat currentscale = scrollview.zoomscale; // adjust object's position. cgpoint currentcenter = yourobject.center; currentcenter.x = initialx * currentscale; currentcenter.y = initialy * currentscale; yourobject.center = currentcenter; }
hope helps.
Comments
Post a Comment