25

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?

ThaDon
  • 7,826
  • 9
  • 52
  • 84
  • 3
    Just to check, it works correctly when you specify a color, like `[UIColor blueColor]` or `[UIColor groupTableViewBackgroundColor]`? Also, what you do probably creates a memory leak: you should use `[UIColor colorWithPatternImage:]` instead. – Gordon Seidoh Worley Oct 13 '09 at 01:59

9 Answers9

53

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)

Amine
  • 562
  • 5
  • 2
  • This worked for me when nothing else did. Set the background color in IB to the grouped Table view color (default). Then in code, set the color to clearColor. I also have the cells marked opaque=NO and clearsContextBeforeDrawing=NO, but those settings alone didn't change anything until I added the clearColor by code – Bdebeez Dec 22 '10 at 20:01
  • 2
    Thank you Amine. It looks like this is now fixed in iOS 5. I was seeing this bug when viewing my app on devices running iOS 4.x, but not on iOS 5. Once I set the UITableView's background color to clear in code it fixed the issue on the iOS 4.x devices. – Christine Nov 17 '11 at 01:34
  • Thanks Amine for this trick. Also I agree with Christine. Apple fixed it in ios5 – iOSAppDev Apr 09 '12 at 08:12
  • I can confirm that this is no longer an issue in iOS 5. To clarify for iOS 4, the backgroundColor property needs to be set in the - viewDidLoad method. Setting the property in -init does not work. – phatblat Apr 16 '12 at 19:46
16

Try this in your controller's viewDidLoad method:

meetingTableView.backgroundColor = [UIColor clearColor];
Cœur
  • 37,241
  • 25
  • 195
  • 267
Imran Raheem
  • 890
  • 8
  • 25
3

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.

Janak Nirmal
  • 22,706
  • 18
  • 63
  • 99
Ray Wenderlich
  • 480
  • 2
  • 8
3

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

surendher
  • 1,374
  • 3
  • 26
  • 52
2

Maybe if you put yourTableViewOutlet.backgroundView=nil;

John Conde
  • 217,595
  • 99
  • 455
  • 496
esses77
  • 21
  • 1
1

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.

ck.
  • 327
  • 1
  • 2
  • 10
  • Not at my Mac at the moment so I'll check that out later. But if they aren't opaque, won't the table cells end up transparent and hence not white? – ThaDon Oct 13 '09 at 14:17
  • Being not-opaque isn't the same thing as having an alpha value < 1.0; it's more an optimization to the drawing system, to let the OS know whether it has to do more expensive compositing, or can just assume the view fills its whole frame. – Sixten Otto Oct 20 '09 at 13:24
  • This worked for me on a non-red background in the owning view. When white the black corners reappear. (In the simulator, anyway.) – Scott McKenzie Dec 19 '10 at 22:15
0

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

Frank Schmitt
  • 25,648
  • 10
  • 58
  • 70
0

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

Madhup Singh Yadav
  • 8,110
  • 7
  • 51
  • 84
0

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.

TomL
  • 759
  • 8
  • 20