由於是自定義的因此我只把自定義的view顯示出來了,自定義的view只要邏輯是對的通常都不會錯(本例中第一個是三個控件加兩條線,第二個是一個tableview),若是對自定義的view有疑問可message me.ide
效果圖:
spa
相關代碼:.net
UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];3d
bgView.backgroundColor = [UIColor colorWithWhite:0.f alpha:0.5];//使背景變暗orm
[self.view addSubview:bgView];rem
InputAlertView *alertView = [[InputAlertView alloc] initWithFrame:CGRectMake(40, 0.3*SCREEN_HEIGHT, SCREEN_WIDTH-80, 150)];get
[bgView addSubview:alertView];input
[[[UIApplication sharedApplication]keyWindow] addSubview:bgView];//使其導航欄也變暗it
alertView.layer.cornerRadius = 5;io
alertView.layer.masksToBounds = YES;
alertView.backgroundColor = [UIColor whiteColor];
alertView.alpha = 1.0;
alertView.inputPwdTF.placeholder = @"請輸入管理員密碼";
alertView.changeInfoLabel.text = @"修改員工信息請輸入管理員密碼";
[alertView.okBtn setTitle:@"確 定" forState:UIControlStateNormal];
[alertView.okBtn bk_addEventHandler:^(id sender) {
[bgView removeFromSuperview];//不用時要移除
MCChangeWorkerInfoViewController *changeInfoVC = [MCChangeWorkerInfoViewController new];
[self.navigationController pushViewController:changeInfoVC animated:YES];
} forControlEvents:UIControlEventTouchUpInside];
自定義tableview型的下拉框效果圖:
相關代碼:
[[[UIApplication sharedApplication]keyWindow] addSubview:bgView];
// 自定義的tableView 提示框
alertTableView *alertview = [[alertTableView alloc] initWithFrame:CGRectMake(60, 0.3*SCREEN_HEIGHT, SCREEN_WIDTH-120, 250) style:UITableViewStyleGrouped];
alertview.titleArr = @[ @"最近7天",@"最近15天",@"最近一月",@"本季度",@"今年"];
[bgView addSubview:alertview];
使背景變暗透明並使自定義的view背景不透明的方法我找到了兩種,代碼中用了一種,另外一種以下:
UIColor *color = [UIColor BlackColor];
bgView.backgroundColor = [color colorWithAlphaComponent:0.5];