When writing a project, to implement a pop-up menu from the bottom, and the background is a deep effect, here to share to everyone.
Mainly talk about ideas and some core code to paste out, to download the source,
Please go to: http://download.csdn.net/download/rhljiayou/6280989
A simple, effective, more practical menu pop-up effect implementation,:
Implementation: Self.view The current page, add a menu view on the top of the current page, which is added in Self.view.superview.
[CPP]View Plaincopy
- Show
- -(void) Show: (uiview*) Parent
- {
- Parentview = parent;
- //Hide backview,table First
- Backview.alpha = 0;
- _table.alpha = 0;
- //Move table
- [_table settransform:cgaffinetransformmaketranslation (0, _table.frame.size.height)];
- //Parent window Add this view,---this will call Viewdidload
- [Parentview.superview AddSubview:self.view];
- //Add animation, add to parent window, make it move from bottom
- [UIView animatewithduration:0.3 animations:^{
- //Parent window Zoom out
- Cgaffinetransform t = Cgaffinetransformmakescale (0.9, 0.9);
- [Parentview Settransform:t];
- //Display backview,table
- Backview.alpha = 1;
- _table.alpha = 1;
- //Move table,cgaffinetransformidentity restore original coordinates
- [_table settransform:cgaffinetransformidentity];
- } completion:^ (BOOL finished) {
- }];
- }
- Hide
- -(void) Hide
- {
- //Add animation, add to parent window, make it move from bottom
- [UIView animatewithduration:0.3 animations:^{
- //Parent window Restore
- Cgaffinetransform t = cgaffinetransformidentity;
- [Parentview Settransform:t];
- //Display backview,table
- Backview.alpha = 0;
- _table.alpha = 0;
- //Move table
- [_table settransform:cgaffinetransformmaketranslation (0, _table.frame.size.height)];
- } completion:^ (BOOL finished) {
- [Self.view Removefromsuperview];
- }];
- }
- -(void) Viewdidload
- {
- [Super Viewdidload];
- Self.view.backgroundColor = [Uicolor Clearcolor];
- //Shadow black cover
- Backview = [[UIView alloc]initwithframe:self.view.bounds];
- Backview.backgroundcolor = [Uicolor colorwithred:0 green:0 blue:0 alpha:0.3];
- [Self.view Addsubview:backview];
- //Calculate the cgrect of table
- CGRect rect = self.view.bounds;
- int height = _titlearray.count * 44;
- RECT.ORIGIN.Y = Rect.size.height-height;
- Rect.size.height = height;
- _table = [[UITableView alloc]initwithframe:rect];
- _table.delegate = self;
- _table.datasource = self;
- [Self.view addsubview:_table];
- }
Reprint Address: http://blog.csdn.net/rhljiayou/article/details/11768963
This menu you can arbitrarily customize, I here is a tableview, you can write some have the picture and text add up. Only need to change the source code slightly, ok!
iOS implementation popup Menu effect Menuviewcontroller (background depth of field pop-up menu)