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];
}
设置父视图的透明度不影响子视图的透明度
最新推荐文章于 2019-08-08 10:46:15 发布