自定義一個全屏的view(subview)覆蓋當前視圖

又是後要強制用戶選擇響應一個事件,那麼就要用一個層覆蓋整個用戶界面。以下是僞碼!

-(void)handleSingleTap:(UIGestureRecognizer *)gestureRecognizer{

    [guideView setHidden:YES];
}
顯示一個view 全屏
-(void)show
{

UIWindow *keyv=[[UIApplication sharedApplication] keyWindow];
UIView *viewss=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
[viewss setBackgroundColor:[UIColor redColor]];
viewss.alpha=0.4;
[keyv addSubview:viewss];

    guideView =[[UIView alloc]initWithFrame:self.navigationController.view.bounds];
    [guideView setBackgroundColor:[UIColor redColor]];
    [guideView setUserInteractionEnabled:YES];
    UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
    
    [guideView addGestureRecognizer:singleTap];
    [self.navigationController.view addSubview:guideView];
    return;

}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章