简体   繁体   中英

Change the colour of tab bar icons and table background under the “More” tab?

I have around 7 tab bar items and hence have been given a 'more' tab bar item. All the other tab bar items are using the 'Original' mode instead of 'Template' but when i select the 'more' tab, the remaining icons are back to 'Template' until they're dragged to the tab bar after pressing edit. As well as this, my other views are tableviews with a coloured background, when i select the 'more' tab, the tableview presented has a white background. I managed to fix this for the tableview but the cells within are white, with the empty cells having the correct colour. Any idea how i'd fix these issues?

使标签栏控制器中的第五项成为自定义表格视图,并将其命名为“更多”,然后自己处理导航。

Managed to fix it with this:

class mainTabBarViewController: UITabBarController, UITabBarControllerDelegate {

    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(true)
        self.moreNavigationController.topViewController.view.backgroundColor = UIColor(red: 25.0/255.0, green: 25.0/255.0, blue: 25.0/255.0, alpha: 1.0)

        var view = self.moreNavigationController.topViewController.view as UITableView

        for cell in view.visibleCells(){
            var tableCell = cell as UITableViewCell
            tableCell.backgroundColor = UIColor(red: 25.0/255.0, green: 25.0/255.0, blue: 25.0/255.0, alpha: 1.0)
            tableCell.textLabel?.textColor = UIColor.whiteColor()
        }

    }
}

Now I just need to find a way to change the background colour for the view when the user presses 'Edit'.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM