在写项目时,要实现一个从下移上来的一个弹出菜单,并且背景变深的这么一个效果,在此分享给大家。
主要说一下思路及一些核心代码贴出来,要想下载源码,
请到:http://download.csdn.net/download/rhljiayou/6280989
一个简单,效果好,比较实用的菜单弹出效果的实现,效果图:

实现方式:将self.view当前页面缩小,在当前页的上面添加一个菜单的view,即在self.view.superview添加。
- - (void) show:(UIView*)parent
- {
- parentView = parent;
-
-
- backView.alpha = 0;
- _table.alpha = 0;
-
-
- [_table setTransform:CGAffineTransformMakeTranslation(0, _table.frame.size.height)];
-
-
- [parentView.superview addSubview:self.view];
-
-
- [UIView animateWithDuration:0.3 animations:^{
-
- CGAffineTransform t = CGAffineTransformMakeScale(0.9, 0.9);
- [parentView setTransform:t];
-
-
- backView.alpha = 1;
- _table.alpha = 1;
-
-
- [_table setTransform:CGAffineTransformIdentity];
-
- } completion:^(BOOL finished) {
-
- }];
-
-
- }
- - (void) hide
- {
-
- [UIView animateWithDuration:0.3 animations:^{
-
- CGAffineTransform t = CGAffineTransformIdentity;
- [parentView setTransform:t];
-
-
- backView.alpha = 0;
- _table.alpha = 0;
-
-
- [_table setTransform:CGAffineTransformMakeTranslation(0, _table.frame.size.height)];
-
- } completion:^(BOOL finished) {
- [self.view removeFromSuperview];
- }];
- }
-
- - (void)viewDidLoad
- {
- [super viewDidLoad];
-
- self.view.backgroundColor = [UIColor clearColor];
-
-
- backView = [[UIView alloc]initWithFrame:self.view.bounds];
- backView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.3];
- [self.view addSubview:backView];
-
-
- 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];
-
- }
转载地址 : http://blog.csdn.net/rhljiayou/article/details/11768963
这个菜单你可以任意自定义,我这里是一个tableView,你可以写一些有图和文字的添加上去。只需要把源代码稍改,就ok!
IOS实现弹出菜单效果MenuViewController(背景 景深 弹出菜单)
原文:http://www.cnblogs.com/wcLT/p/4733631.html