Search code examples
iosuiviewframescale

How to correctly scale and position a view


I have a UIView that originally is the size of 320x90

now I want to scale it, so I wrote

myView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.9,0.8);

the problem is that now my view doesn't sit where I want it to sit, x,y wise

and any changes to its frame's origin does not change its location on the screen

how to put location on the screen after scaling ?


Solution

  • How about doing another transform for your offset by using CGAffineTransformTranslate?:

    myView.transform = CGAffineTransformTranslate(myView.transform, x, y);