iOS implementation popup Menu effect Menuviewcontroller (background depth of field pop-up menu)

Source: Internet
Author: User

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
  1. Show
  2. -(void) Show: (uiview*) Parent
  3. {
  4. Parentview = parent;
  5. //Hide backview,table First
  6. Backview.alpha = 0;
  7. _table.alpha = 0;
  8. //Move table
  9. [_table settransform:cgaffinetransformmaketranslation (0, _table.frame.size.height)];
  10. //Parent window Add this view,---this will call Viewdidload
  11. [Parentview.superview AddSubview:self.view];
  12. //Add animation, add to parent window, make it move from bottom
  13. [UIView animatewithduration:0.3 animations:^{
  14. //Parent window Zoom out
  15. Cgaffinetransform t = Cgaffinetransformmakescale (0.9, 0.9);
  16. [Parentview Settransform:t];
  17. //Display backview,table
  18. Backview.alpha = 1;
  19. _table.alpha = 1;
  20. //Move table,cgaffinetransformidentity restore original coordinates
  21. [_table settransform:cgaffinetransformidentity];
  22. } completion:^ (BOOL finished) {
  23. }];
  24. }
  25. Hide
  26. -(void) Hide
  27. {
  28. //Add animation, add to parent window, make it move from bottom
  29. [UIView animatewithduration:0.3 animations:^{
  30. //Parent window Restore
  31. Cgaffinetransform t = cgaffinetransformidentity;
  32. [Parentview Settransform:t];
  33. //Display backview,table
  34. Backview.alpha = 0;
  35. _table.alpha = 0;
  36. //Move table
  37. [_table settransform:cgaffinetransformmaketranslation (0, _table.frame.size.height)];
  38. } completion:^ (BOOL finished) {
  39. [Self.view Removefromsuperview];
  40. }];
  41. }
  42. -(void) Viewdidload
  43. {
  44. [Super Viewdidload];
  45. Self.view.backgroundColor = [Uicolor Clearcolor];
  46. //Shadow black cover
  47. Backview = [[UIView alloc]initwithframe:self.view.bounds];
  48. Backview.backgroundcolor = [Uicolor colorwithred:0 green:0 blue:0 alpha:0.3];
  49. [Self.view Addsubview:backview];
  50. //Calculate the cgrect of table
  51. CGRect rect = self.view.bounds;
  52. int height = _titlearray.count * 44;
  53. RECT.ORIGIN.Y = Rect.size.height-height;
  54. Rect.size.height = height;
  55. _table = [[UITableView alloc]initwithframe:rect];
  56. _table.delegate = self;
  57. _table.datasource = self;
  58. [Self.view addsubview:_table];
  59. }

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)

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.