Search code examples
iosmatrixtransformcalayerscale

Scaling a UIView from a point other than the center, looking for alternatives to anchorPoint


I've been using CGAffineTransformMakeScale to scale a UIView. This scales it by it's default anchorPoint, which is (.5, .5) -- the center. I'd like to scale it so that it stretches towards the left, as if it were zooming towards the left. I can accomplish this by setting the anchorPoint to the right center. However, this causes problems with setting the frame, etc. Is there a better way to apply a scale transform like I want. I was thinking I could do it with a custom transform matrix, but I am no good with matrix math.


Solution

  • Use anchorPoint, to get around the frame weirdness just store and reload it as in this answer.