我正在開發一個小的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方法並發表評論 –