更改textColor,viewBackground和subview背景

问题描述 投票:0回答:1

我想根据情况更改视图控制器的背景颜色子视图的背景颜色和文本颜色。例如:mainViewcontroller上有2个选项(A和B ViewController)。如果用户选择A ViewController,则它将按照其颜色从A到X,Y,Z ViewsController,直到我按下,执行Segue或显示X,Y,Z View Controller。如果用户选择B ViewController,则它将按照其颜色从B到X,Y,Z ViewsControllers,直到我按下,执行Segue或显示X,Y,Z ViewController。注意:这些子视图可以包括tableView,collectionview,CollectionView中的tableView或tableView中的CollectionView预先感谢。

ios swift viewcontroller generic-programming reusability
1个回答
0
投票
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        if indexPath.row == 0 {
            self.performSegue(withIdentifier: "ThisColorSegue", sender: nil)
        } else if indexPath.row == 1 {
            self.performSegue(withIdentifier: "ThatColorSegue", sender: nil)
        } else if indexPath.row == 2 {
            self.performSegue(withIdentifier: "SomeOtherColorSegue", sender: nil)
        }
    }



  override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "ThisColorSegue", let dest = segue.destination as? ZController {
dest.color = SomeColor
}
© www.soinside.com 2019 - 2024. All rights reserved.