Present a modal view using fade-in animation

后端 未结 3 827
眼角桃花
眼角桃花 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)
    
    0 讨论(0)
  • 2021-01-31 14:14

    Swift 3, 3.1, 4, 4.2 (as of January, 2021)

    var storyboard = UIStoryboard(name: "Main", bundle: nil)
    var loginViewController = storyboard.instantiateViewController(withIdentifier: "login")
    loginViewController.modalTransitionStyle = .crossDissolve
    self.present(loginViewController, animated: true, completion: nil)
    
    0 讨论(0)
  • 2021-01-31 14:16

    You have to set prestentation and transition style:

        self.activityAlertVC.modalPresentationStyle = .custom
        self.activityAlertVC.modalTransitionStyle = .crossDissolve
    
    0 讨论(0)
提交回复
热议问题