UIViewController – issue with custom dismiss transition

后端 未结 2 1479
名媛妹妹
名媛妹妹 2020-12-23 14:41

Summary

I have a content UIViewController that presents a settings UIViewController using a custom transition. The presentation is with presentViewController

2条回答
  •  自闭症患者
    2020-12-23 15:20

    Initially, I thought about using CATransition to have custom transition effect when presentViewController:animated:completion: and dismissViewControllerAnimated:completion: a View Controller. But you want to show a portion of View Controller when the setting View Controller is presented, then I think CATransition would not help because you don't have full control of how far you want to move the View Controller.

    I think the easiest way is to have one single View Controller with two full screen UIView. For the first UIView (View Controller's view, that is, self.view), you layout the setting, and on the second UIView, it's the regular View. In the ViewDidLoad, you add the 2nd view by using [self.view addSubview:2ndView];. Later when you want to present the setting view, you can do

    CGRect frame = secondView.frame;
    frame.origin.y = the_y_coordinate_you_like;
    UIView animateWithDuration:0.2 animations:^{
        secondView.frame = frame;
    }];
    

    then do the other way to bring the 2ndView back.

提交回复
热议问题