Why is my UIView not growing with CGAffineTransformMakeScale?

后端 未结 2 1581
醉话见心
醉话见心 2021-01-27 09:48

My goal is to make a view grow double in size. The result I get with the code I have is \"nothing happens\". The view displays but doesn\'t grow. Any help would be appreciated.<

相关标签:
2条回答
  • 2021-01-27 09:53

    The problem is that this is a view transform and you are using auto layout. Auto layout works by setting the frame of your view. Thus you apply a transform and then auto layout comes along and changes it back again.

    I regard this as a major bug ever since the introduction of auto layout; it's as if the auto layout people did not think deeply enough about how iOS works before they introduced this feature. See my "essay" on this topic here: https://stackoverflow.com/a/14105757/341994

    0 讨论(0)
  • 2021-01-27 10:09

    When you see the square on screen, the transformation is already happened. Try putting the scaling code in viewDidAppear instead of viewWillAppear.

    Another small remark: you forgot to call

    [super viewWillAppear]. 
    
    0 讨论(0)
提交回复
热议问题