static UIView *modalview;
If(Modalview) {[Modalview Removefromsuperview]; Modalview=Nil; return; } cgrect Screen=[[UIScreen mainscreen] bounds]; CGRect bounds= CGRectMake (screen.origin.x, SCREEN.ORIGIN.Y, Screen.size.width, screen.size.height/2); Modalview=[[UIView alloc] initwithframe:bounds]; Modalview.opaque=NO; Modalview.backgroundcolor= [[Uicolor blackcolor] Colorwithalphacomponent:0.5f]; UILabel*label =[[UILabel alloc] init]; Label.text=@"Modal View"; Label.textcolor=[Uicolor Whitecolor]; Label.backgroundcolor=[Uicolor Clearcolor]; Label.opaque=NO; [Label SizeToFit]; [Label Setcenter:cgpointmake (ModalView.frame.size.width/2, ModalView.frame.size.height/2)]; [Modalview Addsubview:label]; [Self.view Addsubview:modalview];
To load the appearance of the UI from Xib, then:
if (Popupviewcontroller) { [Popupviewcontroller.view Removefromsuperview]; = Nil; return ; } = [[Uiviewcontroller alloc] Initwithnibname:@ "View" Bundle:nil]; [Self.view AddSubview:popupViewController.view];
If you want the animation from the bottom of the animation up slide in:
UIView *popview = popupviewcontroller.view; = popview.bounds; = [[UIScreen mainscreen] bounds]; [Popview setframe:cgrectmake (0, screen.size.height, Orig.size.width, Orig.size.height)]; [UIView beginanimations: @" Animatepopview " Context:nil]; [UIView setanimationduration: 0.4 ]; [Popview setframe:cgrectmake (0, screen.size.height-orig.size.height, Orig.size.width, Orig.size.height)]; [UIView commitanimations];
Half-screen bottom pop-up box in iOS