ios - 自定义 MoreNavigationController 的 Cell

标签 ios swift uitabbarcontroller

我正在尝试让更多 View 与我的应用主题相匹配

enter image description here

表格单元格没有改变背景颜色。我已经尝试了几乎所有这里的答案和互联网上的博客。

tabBarController?.moreNavigationController.topViewController?.view.backgroundColor = UIColor.blackColor()

我已经使用上面的代码实现了图像中显示的当前场景。

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()
}

最佳答案

这是一个很晚的答案,但我无法在网上的任何地方找到解决这个问题的单一方法,即使在 UITabBarController 的 moreNavaigationController 中设置表格 View 和单元格的颜色应该是你可以在 Storyboard。我觉得这是 Swift/xcode 开发人员的疏忽。

就是说,在 UITabBarControllerviewDidAppear 方法中:

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
        }
    }
}

如果您在 viewDidLoad 方法中执行此代码,则此代码将不起作用。我希望这段代码可以帮助正在努力寻找解决方案的人!

关于ios - 自定义 MoreNavigationController 的 Cell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32804566/

相关文章:

iphone - 在 iPad 1 中收到内存警告,但在 iPad 2 和 3 中工作正常

iPhone 4 根据 GPS 纬度和一年中的某一天以编程方式计算日持续时间

ios - 解析错误的 UI

ios - 如何在 var 名称中使用 #。 JSON、iOS、 swift

ios - 在 ios 13 中设置 bounds.height 不再起作用

ios - 禁用 "Edit"选项卡栏 ios 的更多选择中出现的按钮

ios - 使用自定义 NSURLProtocol 时 WebView 无法处理响应

ios - 尝试在 UIView 中为 SKNode 设置动画

ios - 应用因 UITabBarController 和应用内购买而崩溃

ios - 如何在 didSelectRow 之后关闭 UISearchController?