我想在UITableViewCells之間有透明度。單元格之間的空間。UITableViewCells之間的透明度
予用戶自定義創建的細胞和用於設定背景我使用此代碼:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CustomCell = @"CustomBookingCell";
currentBooking = [arrayBookings objectAtIndex:indexPath.row];
CustomBookingCell *cell = (CustomBookingCell *)[tableView dequeueReusableCellWithIdentifier:CustomCell];
if (cell == nil) {
UIViewController *c = [[UIViewController alloc] initWithNibName:@"CustomBookingCell" bundle:nil];
cell = (CustomBookingCell *)c.view;
[ c release ];
}
bookingImage = [[UIImageView alloc] initWithImage:
[UIImage imageNamed:currentBooking.imageSource]];
[cell.imageForBooking addSubview:bookingImage];
cell.selectionStyle = UITableViewCellSelectionStyleGray;
cell.contentView.backgroundColor = [UIColor clearColor];
UIView* backgroundView = [[UIView alloc] initWithFrame:CGRectZero];
UIImage* bgImage = [UIImage imageNamed:@"Background_300_82.png"];
UIColor *bgColor = [[UIColor alloc] initWithPatternImage: bgImage];
backgroundView.backgroundColor = bgColor;
cell.backgroundView = backgroundView;
cell.label.text = currentBooking.title;
[bookingImage release];
[bgColor release];
[backgroundView release];
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 90;
}
單元格的高度高10個像素,所述tableCellBg.png。 我的背景視圖也有一個圖像作爲背景(當然,這個背景應該顯示在單元格之間)。
所以我試着在透明底下添加10個像素到底部的tableCellBg.png來解決這個問題。但細胞之間的空間是黑色的。我看不到我的單元格之間的視圖背景。
我該怎麼辦?我是否必須用tableCellBg.png的高度在cellForRowAtIndexPath中創建一個UIView,然後將Custom UITableViewCell作爲子視圖添加到創建的具有較低高度的UIView中?
還是有更簡單的方法來完成這個?
我試圖創建一個黑色的圖像,然後我增加了canvaz尺寸並添加了10個像素的透明度。但是這種透明度變成黑色,就像UITableViewCell backgroundView不支持透明圖像。 – 2010-09-23 09:38:14