Iphone UITableViewCells之间的透明度
我希望UITableViewCells之间具有透明度。细胞之间的空间 我使用用户自定义创建的单元格,并使用以下代码设置背景:Iphone UITableViewCells之间的透明度,iphone,cocoa-touch,uikit,Iphone,Cocoa Touch,Uikit,我希望UITableViewCells之间具有透明度。细胞之间的空间 我使用用户自定义创建的单元格,并使用以下代码设置背景: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CustomCell = @"CustomBookingCell"; currentBooking = [ar
- (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;
}
单元格的高度比tableCellBg.png高10个像素。
我的背景视图也有一个图像作为背景。当然,这个背景应该显示在单元格之间
因此,我尝试在底部的tableCellBg.png中添加10个透明像素来解决这个问题。但是细胞之间的空间是黑色的。我看不到单元格之间的视图背景
我该怎么办?我是否必须在cellForRowAtIndexPath中创建一个具有tableCellBg.png高度的UIView,然后将自定义UITableViewCell作为子视图添加到创建的UIView中,并具有较高的高度
还是有更简单的方法来实现这一点?您的表视图需要清晰的背景色。比如说
myTableView.backgroundColor = [UIColor clearColor];
您的表格视图需要清晰的背景色。比如说
myTableView.backgroundColor = [UIColor clearColor];
我通过使用另一种方法将背景图像添加到UITableViewCell来解决此问题:
UIImage *image = [UIImage imageNamed:@"ny_bg_event.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
imageView.frame = CGRectMake(0, 0, 300, 84);
cell.backgroundView = imageView;
cell.backgroundColor = [UIColor clearColor];
[imageView release];
[cell setFrame:CGRectMake(0, 0, 300, 84)];
cell.contentView.backgroundColor = [UIColor clearColor];
我没有创建UIView,而是使用UIImageView。我通过使用另一种方法将背景图像添加到UITableViewCell来解决这个问题:
UIImage *image = [UIImage imageNamed:@"ny_bg_event.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
imageView.frame = CGRectMake(0, 0, 300, 84);
cell.backgroundView = imageView;
cell.backgroundColor = [UIColor clearColor];
[imageView release];
[cell setFrame:CGRectMake(0, 0, 300, 84)];
cell.contentView.backgroundColor = [UIColor clearColor];
我没有创建UIView,而是使用UIImageView。我尝试创建一个黑色的图像,然后我增加了canvaz大小,并增加了10个像素的透明度。但是这种透明度变为黑色,就像UITableViewCell backgroundView不支持透明图像一样。我尝试创建一个黑色图像,然后我增加了canvaz大小并添加了10像素的透明度。但这种透明度变为黑色,就像UITableViewCell backgroundView不支持透明图像一样。背景图像的高度为82像素。背景图像的高度为82像素。