iOS 8透明tableView

时间:2014-12-02 11:07:39

标签: ios uitableview ios8 transparent

我有一个UITableView,但我没有设法让它在iOS8中透明,而只是白色。

使用View Hierarchy Debugging,我清楚地看到它是不透明白色的tableView: enter image description here

我在代码中创建表视图:

    _list = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height) style:UITableViewStylePlain];
    _list.backgroundColor = [UIColor clearColor];
    _list.opaque = NO;

但是,backgroundColor和opaque属性似乎没有效果,因为以下代码在白色不透明的tableView中得到了结果:

    _list = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height) style:UITableViewStylePlain];
    _list.backgroundColor = [UIColor redColor]; //setting to red does have no effect, tableview is still white
    _list.opaque = NO;

我想通过首先设置UIScrollView的外观,我可以将不透明颜色设置为白色以外的颜色,如下所示:

    [[UIScrollView appearance] setBackgroundColor:[UIColor redColor]];
    _list = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height) style:UITableViewStylePlain];

所以这将导致一个RED tableView(独立于我是否将_list.backgroundColor设置为其他东西)。

不幸的是,在UIScrollView外观上设置opaque属性并不会产生透明的tableview ..所以,下面的代码也给了我一个白色不透明的tableview:

    [[UIScrollView appearance] setBackgroundColor:[UIColor clearColor]];
    [[UIScrollView appearance] setOpaque:NO];
    _list = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height) style:UITableViewStylePlain];

此问题在iOS 7中不存在,仅出现在iOS8中。我该如何解决这个问题?

0 个答案:

没有答案