UITableViewCell show white background and cannot be modified on iOS7
As Apple DOC said (UITableViewCell Class Reference):
... In iOS 7, cells have a white background by default; in earlier versions of iOS, cells inherit the background color of the enclosing table view. If you want to change the background color of a cell, do so in the tableView:willDisplayCell:forRowAtIndexPath: method of your table view delegate.
So for my case that to show cells with transparent background, just need to implement the delegate method in the table view controller like below:
- (void)tableView:(UITableView *)tableView
willDisplayCell:(UITableViewCell *)cell
forRowAtIndexPath:(NSIndexPath *)indexPath
{
[cell setBackgroundColor:[UIColor clearColor]];
}
Just Note: As @null said, "...there seems to be a bug in interface builder...", I'm not totally sure whether it does have the bug, but seems so cause his comment got several up votes. So there might something wrong if you use IB. :)
UITableView / UITableViewCell challenge with transparent background on iPad with iOS7
After wasting multiple hours with interface builder, I'm thinking that there might be a bug there. So I started to look for a programatic answer. Apparently had I started here I could have saved a ton of time. By adding to the method:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
I was able to solve the transparency issue on iPad by adding this one line:
cell.backgroundColor = [UIColor clearColor]; // Adding this fixes the issue for iPad
Hope this helps everyone else with the white background seen for ipad with tables and iOS7!
White background is showing above UISearchBar for iOS7
I managed to get rid of that color by setting a table view background view.
UIView *backgroundView = [[UIView alloc] initWithFrame:self.tableView.bounds];
backgroundView.backgroundColor = [UIColor clearColor];
self.tableView.backgroundView = backgroundView;
Programmatically created UITableView always white in iOS9
init
method is not a good place to modify UI properties because the view hierarchy hasn't been constructed yet.
Try using layoutSubviews
or didMoveToWindow
for UIView
subclasses:
var customColor = UIColor.yellowColor()
override func layoutSubviews() {
super.layoutSubviews()
self.backgroundColor = customColor
}
override func didMoveToWindow() {
super.didMoveToWindow()
self.backgroundColor = customColor
}
You can also use viewDidLoad
or awakeFromNib
methods in UIViewController
subclasses:
override func viewDidLoad() {
super.viewDidLoad()
customTableView.backgroundColor = UIColor.yellowColor()
}
override func awakeFromNib() {
super.awakeFromNib()
customTableView.backgroundColor = UIColor.yellowColor()
}
UITableView checkmark has a white background
Instead of accessoryview
you can use imageview
to show Checked record.
UITableView with custom cells draws fine on iOS 6 but completely white in iOS 7
setcontentview
backgroundColor
to clear color
Can't set background color of UITableViewCell in IB
There's an easier solution: When you create a UITableViewCell
in Interface Builder, simply drag and drop an additional UIView
so that it covers the entire UITableViewCell
you're creating within IB. Place your additional UI elements on top of this additional UIView
. You can set this extra UIView
to whatever background you like.
There are quite a few answers on StackOverflow that suggest you change the background color of your UITableViewCell
by using a line of code like this one:
cell.contentView.backgroundColor = [UIColor redColor];
If you add a drop shadow to your cell by adjusting the contentView
's frame size slightly, you may find that this line will change both the background color of your cell and the color of your drop shadow area as well.
Related Topics
Get the Right Color in iOS7 Translucent Navigation Bar
What Should Xcode 6 Gitignore File Include
How to Remove Provisioning Profiles from Xcode
How to Determine Height of Uicollectionview with Flowlayout
Access Container View Controller from Parent iOS
Uitableview Within Uiscrollview Using Autolayout
Uistackview Distribution Fill Equally
Creating Delegates on the Spot with Blocks
iOS How to Detect When App Was Removed from Process
How to Get the Udid in iOS 6 and iOS 7
Run Timer in 'Background' When App Is Closed
How to Save a Uicolor with Userdefaults
Custom Rounding Corners on Uiview
Storing Asynchronous Cloud Firestore Query Results in Swift
How to Display Activity Indicator in Center of Uialertcontroller