Black corners on UITableView Group Style

2019-02-02 04:02发布

I have a problem where my UITableView (group style) has a black "tip" above it's rounded corner.

I'm setting up the background of the tableview like so:

[meetingTableView setBackgroundColor:[[UIColor alloc] initWithPatternImage:[[UIImage alloc] initWithContentsOfFile:@"background.png"]]];

And my table view ends up looking like this:

black pointy edge on rounded corner http://papernapkin.org/pastebin/resource/images/imageEntryId/6487

Any ideas how I can get rid of those black points?

9条回答
ら.Afraid
2楼-- · 2019-02-02 04:30

You'll get Black corners on UITableView Group Style if you set background color to clear color in XIB.

Instead try this code for removing Black corners on UITableView Group Style

tableViewObject.backgroundColor=[UIColor clearColor];

查看更多
神经病院院长
3楼-- · 2019-02-02 04:30

My guess is that it's related to something that you're doing in your custom table view cells. You might want to experiment with setting the cell background color to [UIColor clearColor].

查看更多
forever°为你锁心
4楼-- · 2019-02-02 04:32

I have got the same problem. When I set clear color by xib, I have the back corner The solution is to set it by code !

(The same problem with interface builder exist for webviews)

查看更多
淡お忘
5楼-- · 2019-02-02 04:40

I think you should set the background color of your table as clearColor and initialsie your view with the background image.

Then it will definitely not show the black corners. But also don't forget to set the background color of your cell as white color

查看更多
姐就是有狂的资本
6楼-- · 2019-02-02 04:41

To avoid the black corners you have to make sure that the UITableViewCells are not opaque. It looks like you're using custom styles table cells and the default value for opaque is YES. Either go to Interface Builder and uncheck the opaque checkbox if the table cell was set up in a XIB file. Or use the setOpaque:NO setter to change value.

Because the table cell view still has a rectangular frame even with the rounded corners the cell view and not the actual table view is causing those black corners.

查看更多
一纸荒年 Trace。
7楼-- · 2019-02-02 04:41

The up-voted answer above (set the tableView's background to [UIColor clearColor]) may not work for you if you are like me and never use the UITableViewController, instead putting a UITableView inside a UIViewController.

In this case it's not the tableView that needs to have a clear background, but the view that holds the tableview.

This is not intuitive, but it works for me. In interface builder you can just set the parent view's background color to clear color, or you could do the same in code in viewDidLoad with:

self.view.backgroundColor = [UIColor clearColor];

I'm guessing the reason for the black corners is something about the internal graphics optimization, and setting the background clear fixes it.

查看更多
登录 后发表回答