【问题标题】:Does a grouped UITableView give its backgroundColor to its cells?分组的 UITableView 是否将其背景颜色赋予其单元格?
【发布时间】:2011-01-31 16:43:44
【问题描述】:

我想要一个 UITableView 的背景图片

假设您已经像这样初始化任何分组表:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

// Override point for customization after application launch
ImageTableViewController *vc = [[ImageTableViewController alloc] initWithStyle:UITableViewStyleGrouped];


 NSString *imagePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"BackgroundImage.jpg"];
 UIImage *image = [[[UIImage alloc] initWithContentsOfFile:imagePath] autorelease];
 vc.tableView.backgroundColor = [UIColor colorWithPatternImage:image];

 [window addSubview:vc.view];
    [window makeKeyAndVisible];

 return YES;
}

这导致 tableView 具有背景图像,而且每个单元格都具有图像的最下部。

我想是这样的,因为 UITableViewCell 应该具有与 UITableView 相同的背景颜色。它适用于颜色,但对于图像,情况就完全不同了。

有没有办法告诉 UITableViewCell 不要使用这张图片?

【问题讨论】:

    标签: image uitableview colors background


    【解决方案1】:

    覆盖 tableView:willDisplayCell:forRowAtIndexPath: 并给单元格一个透明背景

    【讨论】:

    • 我需要设置圆角矩形外区域的背景。 backgroundColor 属性正在处理它内部的区域。
    • 对不起 - 我想:有没有办法告诉 UITableViewCell 不要使用这个图像 - 意味着你想摆脱单元格中的图像
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-12-23
    • 2014-09-08
    • 2018-11-24
    • 2015-07-11
    • 2019-04-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多