How do I present a UIViewController by zooming?

前端 未结 3 1779
感情败类
感情败类 2021-02-14 18:42

In my iPad app I have a view controller with a small table view. When you tap on the table view it opens a modal view controller that is a larger and more refined version of the

3条回答
  •  清歌不尽
    2021-02-14 19:08

    UIKit takes care of most of this for you. While jbat100's solution could be made to work too, you should be able to do this simply by setting lvc's initial frame to the smaller rect you want to start out at and then when you set the frame too its full size, the implicit animation for changing the frame will handle the zooming animation for you. Each UIView has a CALayer that its content is drawn in and that layer has several implicit animtions setup to animated changes to certain properties such as the frame or position properties. Here is my untested stab at it:

           .
           .
       lvc.view.frame = CGRectMake(50,50,200,300);
       [self performSelector:@selector(setFrameToFullScreen) withObject:nil afterDelay:0];
    
    }
    
    - (void)setFrameToFullScreen {
       lcv.view.frame = [UIScreen mainScreen].bounds;
    }
    

    The performSelector:withObject:afterDelay call will cause setFrameToFullScreen to be called on the next run loop cycle. If you don't do something like that, then only the final frame will be used and the system won't recognize the change in the frame and apply its implicit animation to the views layer.

提交回复
热议问题