ios - Applying just the scale component of a CGAffineTransform to a UIView -
i have uiview various scale , rotation cgaffinetransforms have been applied, in response touch screen gestures.
when scale operation completes, want adjust bounds of view new size, have view re-draw @ scale of 1.0, while keeping other components of transform same.
to adjust bounds of view, i'm using:
self.myview.bounds = cgrectapplyaffinetransform(self.myview.bounds, self.myview.transform);
to "undo" scale transform, i'm trying this:
self.myview.transform = cgaffinetransformconcat(self.myview.transform, cgaffinetransformmakescale(1, 1));
then calling [myview setneedsdisplay]
view redraw itself.
however not produce desired results , when rotate transform applied, above code seems cause looks sideways translation transform applied too.
what's cleanest way "undo" scale transform , have view redraw @ 1:1 other transforms remaining intact?
i handling similar, , store separate components in struct (scale, rotation, translation). way can recreate transform again (be careful order of operations though).
one thing though: suggest don't change bounds , instead apple scale operation transform. avoid potential unneeded layouts. of stuff can handled purely transform property. way doing not going change since applying scale of 1 no-op. if scaled view 2, need scale 0.5 original. or, said above, store components , recreate identity matrix (matrix math fast, don't worry that).
Comments
Post a Comment