iOS presentViewController launches half-screen transparent UIViewController
No nonsense, just go to the code
1. How to open the parent page
/** * page open configuration * * @param sender <#sender description#> */ - (IBAction)shwoViewAction:(id)sender { TTViewController *tView = [[TTViewController alloc] init]; //Set the mode display style [tView setModalPresentationStyle:UIModalPresentationOverCurrentContext]; // Required configuration self.modalPresentationStyle = UIModalPresentationCurrentContext; self.providesPresentationContextTransitionStyle = YES; self.definesPresentationContext = YES; [self presentViewController:tView animated:YES completion:nil]; }
2. Subpage rewrite viewWillLayoutSubviews, set position width and height
#define DeviceHeight [[UIScreen mainScreen] bounds].size.height #define DeviceWidth [[UIScreen mainScreen] bounds].size.width /** * Set the position width and height */ - (void)viewWillLayoutSubviews { self.view.frame = CGRectMake(self.view.frame.origin.x, DeviceHeight / 2, DeviceWidth, DeviceHeight / 2); //self.view.backgroundColor = [UIColor clearColor]; //self.view.backgroundColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:0.868f]; }
Finish work.