Present a modal view using fade-in animation

后端 未结 3 898
眼角桃花
眼角桃花 2021-01-31 13:30

I presented a login screen as follows modally. Correct me if I am not right.

   UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@\"Main\" bundle:nil]         


        
3条回答
  •  忘掉有多难
    2021-01-31 14:12

    Just set the modalTransitionStyle property for the viewController. (Documentation)

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    UIViewController *ivc = [storyboard instantiateViewControllerWithIdentifier:@"login"];
    [ivc setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
    [self presentViewController:ivc animated:YES completion:nil];
    

    In Swift:

    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let viewController = storyboard.instantiateViewController(withIdentifier: "login")
    viewController.modalTransitionStyle = .crossDissolve
    present(viewController, animated: true, completion: nil)
    

提交回复
热议问题