示例代码如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
- (IBAction)modal:(id)sender {
UIStoryboard * sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
ModalViewController * mvc = [sb instantiateViewControllerWithIdentifier:@"ModalViewController"];
self.definesPresentationContext = YES;//允许设置模态跳转的样式
mvc.modalPresentationStyle = UIModalPresentationOverCurrentContext;//设置模态跳转的样式
[self presentViewController:mvc animated:true completion:nil];
}
运行结果: