Recent projects require a semi-transparent view of the modal, and many people encounter this problem, setting the background color in the target view and then discovering that the modal action ended up with a black or not translucent color.
So today to tell you the solution
-(ibaction) Avtion1: (ID) Sender {testviewcontroller * TESTVC = [Testviewcontroller new]; Self.definespresentationcontext = YES; Self is presenting view Controller TestVC.view.backgroundColor = [uicolor colorwithred:0 green:0 blue:0 alpha:.4]; Testvc.modalpresentationstyle = Uimodalpresentationovercurrentcontext; [Self PRESENTVIEWCONTROLLER:TESTVC animated:yes completion:nil];}
- definespresentationcontext
/* determines which parent view controller ' s view should be presented over for presentation S of type Uimodalpresentationcurrentcontext. If No ancestor View controller has this flag set and then the presenter would be the root view controller.*/
设置你的背景颜色
/* Defines the transition style that will be used for this view controller when it is presented modally. Set this property on the view controller to be presented, not the presenter. Defaults to UIModalTransitionStyleCoverVertical.*/
IOS simulates a translucent viewcontroller Presentviewcontroller implementation