如何在不同的UIViewController中使用自定义叠加视图

时间:2012-08-24 12:15:48

标签: iphone ipad

我正在使用自定义叠加UIView类

#import "OverLayView.h"

@implementation OverLayView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
       self->overLay  = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1024, 704)];
        self->overLay.backgroundColor = [UIColor colorWithWhite:0 alpha:.5];

    }
    return self;
}

-(void)removeOverLay{

    [self->overLay removeFromSuperview];
}

我正在点击操作

   OverLayView *m_overLay = [[UIView alloc]initWithFrame:
                              CGRectMake(0,0,1004,768)]; 
    [m_overLay setBackgroundColor:[UIColor colorWithRed:0. green:0.39 blue:0.106 alpha:0.5]];
    [self.view addSubview:m_overLay];

    CGRect rect = CGRectMake(0, 0, 1024, 704);

    secondViewController = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:[NSBundle mainBundle]];
    [secondViewController.view setFrame:CGRectMake(300, 60, 430, 620)];
    [self.view addSubview:secondViewController.view];

我正在使用类型为UIView的表达式来初始化叠加视图* _strong'的不兼容指针类型。

当我加载时,我需要从secondViewController调用removeOVerLay,这将删除已创建的叠加层

任何人都可以建议我如何删除叠加层

@thanks提前

2 个答案:

答案 0 :(得分:0)

你可以通过给予动画效果来自定义UIViewController中的叠加视图。

参考overlay-another-uiview链接。希望希望

答案 1 :(得分:0)

  

使用NSNotification解决问题!