开发者

Black corners on UITableView Group Style

开发者 https://www.devze.com 2022-12-08 03:23 出处:网络
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:

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] initWithC开发者_如何转开发ontentsOfFile:@"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?


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)


Try this in your controller's viewDidLoad method:

meetingTableView.backgroundColor = [UIColor clearColor];


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];


Just in case you weren't already aware, there's another neat technique you can use to make customized backgrounds for UITableViews:

Not quite as simple as setting the background as you're doing, but it gives you a lot more flexibility and can scale to any table size.


Maybe if you put yourTableViewOutlet.backgroundView=nil;


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.


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].


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号