I am trying to make the more view to match my app theme
The table cells are not changing background color. I have tried almost all the answers here and blogs over the internet.
tabBarController?.moreNavigationController.topViewController?.view.backgroundColor = UIColor.blackColor()
I have used the above code to achieve the current scenario shown in image.
override func viewDidLoad() {
self.homeTableView.registerNib(UINib(nibName: "Banner", bundle: nil), forCellReuseIdentifier: "Banner")
self.homeTableView.registerNib(UINib(nibName: "Heading", bundle: nil), forCellReuseIdentifier: "Heading")
self.homeTableView.registerNib(UINib(nibName: "ThumblessList", bundle: nil), forCellReuseIdentifier: "ThumblessList")
self.homeTableView.registerNib(UINib(nibName: "MapCell", bundle: nil), forCellReuseIdentifier: "MapCell")
self.homeTableView.registerNib(UINib(nibName: "CallButton", bundle: nil), forCellReuseIdentifier: "CallButton")
self.searchBar.showsCancelButton = true
self.edgesForExtendedLayout = UIRectEdge.None
self.extendedLayoutIncludesOpaqueBars = false
self.automaticallyAdjustsScrollViewInsets = false
tabBarController?.moreNavigationController.topViewController?.view.backgroundColor = UIColor.blackColor()
}
This is a very late answer, but I could not find a single solution to this problem anywhere online, even though setting the colour of the table view and the cells in the moreNavaigationController of a UITabBarController should be something you can do in the storyboard. I feel like this is an oversight from the Swift/xcode devs.
That said, in the viewDidAppear
method of your UITabBarController
:
override func viewDidAppear(_ animated: Bool) {
if let moreTableView = moreNavigationController.topViewController?.view as? UITableView {
moreTableView.backgroundColor = UIColor.YOURCOLOUR
for cell in moreTableView.visibleCells {
cell.backgroundColor = UIColor.YOURCOLOUR
}
}
}
This code will not work if you do it in the viewDidLoad
method. I hope this code helps someone who is struggling to find a solution!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With