如何在转换中使ECSlidingViewController视图控制器变暗?

时间:2014-09-15 21:49:26

标签: ios objective-c ecslidingviewcontroller

控制器的documentation mentions adding shadows被设置为动画以显示幻灯片菜单。但是,我想使动画视图控制器更暗,而不是阴影。这可能吗?

1 个答案:

答案 0 :(得分:1)

我只是创建了一个屏蔽视图,并在来自slidingviewcontroller的通知中显示/删除它。添加了一些漂亮的淡入和淡出动作效果:)希望这有帮助

#import <UIKit/UIKit.h>
UIView *overLayView;
@interface MyViewController : UIViewController {
    UIView *overLayView;
}
@end

@implementation MyViewController
- (void)viewDidLoad
{
    [super viewDidLoad];

    overLayView  = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    overLayView.backgroundColor = [UIColor blackColor];
}
-(void) viewWillAppear:(BOOL)animated{
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(disableView) name:ECSlidingViewUnderLeftWillAppear object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(enableView) name:ECSlidingViewTopWillReset object:nil];
}
- (void)viewWillDisappear:(BOOL)animated{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:ECSlidingViewUnderLeftWillAppear object:nil];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:ECSlidingViewTopWillReset object:nil];
}

-(void) disableView {

    overLayView.alpha = 0;

    [self.view addSubview:overLayView];

    [UIView animateWithDuration:0.5 animations:^{
        overLayView.alpha += kViewHelperUIViewMaskAlpha;
    }];
}

-(void) enableView {
    [UIView animateWithDuration:0.5 animations:^{
        overLayView.alpha -= kViewHelperUIViewMaskAlpha;

    } completion:^(BOOL fin){
        if(fin){
            [overLayView removeFromSuperview];
        }
    }];
}

@end