Half-screen bottom pop-up box in iOS

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.