您的位置:首页 > 其它

设置父视图的透明度不影响子视图的透明度

2016-01-05 13:35 399 查看
UIView *BGView = [[UIView alloc]initWithFrame:frame];
BGView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];//设置父视图的透明度不影响子视图的透明度

[self addSubview:BGView];

AlertBgView = [[UIView alloc]initWithFrame:CGRectMake(WIDTH/4, HEIGHT/3, WIDTH/2, HEIGHT/3)];
AlertBgView.center = self.center;
AlertBgView.backgroundColor = [UIColor clearColor];

[BGView addSubview:AlertBgView];

UITableView *Table = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, CGRectGetWidth(AlertBgView.frame), CGRectGetHeight(AlertBgView.frame)) style:UITableViewStylePlain];
Table.layer.masksToBounds = YES;
Table.layer.cornerRadius = 10;
Table.delegate = self;
Table.dataSource = self;
[AlertBgView addSubview:Table];
NSArray *Arr = @[@"确定",@"取消"];
for (int index = 0; index < 2; index ++) {
UIButton *button = [UIButton buttonWithType: UIButtonTypeCustom];
button.frame = CGRectMake(CGRectGetWidth(AlertBgView.frame)/2*index, CGRectGetMaxY(Table.frame)+10, CGRectGetWidth(AlertBgView.frame)/2, 30);
button.layer.cornerRadius = 10;
[button setTitle:Arr[index] forState:UIControlStateNormal];
button.backgroundColor = [UIColor orangeColor];
button.layer.masksToBounds = YES;
[AlertBgView addSubview:button];
}


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: