我正在开发一个小的iOS组件,我有一个半透明的视图与子视图的问题。这是我的情景:
- 一个视图使用[UIColor colorWithRed:green:blue:alpha]
半透明背景 - 有点UITableView
,用alpha = 1.0
,添加作为一个子视图到半透明,
- 其他一些子视图tableview作为subview在半透明视图
一切正常但是当UITableView
向上或向下滚动时,问题会上升,实际上UITableView
周围的半透明视图的区域失去了透明度,变得比其原始背景颜色更暗。
下面是一个图片说明问题:
看具有两个箭头的空间...
谁能帮我解决这个问题?
非常感谢您的关注!
更新:
一些代码:
_alertBg = [[UIView alloc] initWithFrame:CGRectZero];
_alertBg.backgroundColor = self.backgroundColor;
_alertBg.frame = CGRectMake((_bgView.frame.size.width - 240)/2, (_bgView.frame.size.height - 260)/2, 240, 260);
_alertBg.layer.cornerRadius = 8.0;
_alertBg.layer.borderWidth = 2.0;
_alertBg.layer.borderColor = self.borderColor.CGColor;
_alertBg.layer.shadowColor = [UIColor grayColor].CGColor;
_alertBg.layer.shadowOffset = CGSizeMake(0, 3);
_alertBg.layer.shadowOpacity = 0.8;
_alertBg.layer.masksToBounds = YES;
[_bgView addSubview:_alertBg];
_table = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
_table.frame = CGRectMake(10, _titleLabel.frame.origin.y + _titleLabel.frame.size.height + 12, _alertBg.frame.size.width - 20, 150);
_table.layer.cornerRadius = 6.0;
_table.layer.masksToBounds = YES;
_table.delegate = self;
_table.dataSource = self;
[_alertBg addSubview:_table];
从上面的代码,self.backgroundColor
是一样的东西[UIColor colorWithRed:0 green:0 blue:1 alpha:0.7]
可能有助于了解如何创建这些意见的CGRect信息。 IB或计划建设? – Bejmax
一切都是用简单的看法和一些QuartzCore代码,没有IB或做的CGRect ...我编辑的职位,并添加一些代码 – matteodv
@matteodv请加cellForRawAtIndexPath方法并发表评论 –