我要刷新的tableView外觀後,我按「黑暗模式」。但它看起來像這樣: Before press"Dark mode" After press"Dark mode" 我怎麼能刷新這個的tableView後,我改變了它的外觀刷新的tableView外觀
mycode的:
@IBAction func setDarkMode(sender: UISwitch) {
UIView.animateWithDuration(0.5, delay:0,options:UIViewAnimationOptions.BeginFromCurrentState, animations: {() -> Void in
self.setStyleMode()
}) { (finish: Bool) -> Void in
}
}
func setStyleMode() {
if isDarkMode {
view.backgroundColor = UIColor(red:0.1922, green:0.1922, blue:0.1922, alpha:1.0)
self.tableView.backgroundView?.backgroundColor = UIColor(red:0.1922, green:0.1922, blue:0.1922, alpha:1.0)
tableView.separatorColor = UIColor(red:0.3137, green:0.3137, blue:0.3137, alpha:1.0)
self.navigationController?.navigationBar.barTintColor = UIColor(red:0.1451, green:0.1451, blue:0.1451, alpha:1.0)
self.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor(red:0.6549, green:0.6549, blue:0.6549, alpha:1.0)]
self.navigationController?.navigationBar.tintColor = UIColor(red:0.9412, green:0.3412, blue:0.302, alpha:1.0)
for sectionIndex in 0...tableView.numberOfSections - 1 {
for rowIndex in 0...tableView.numberOfRowsInSection(sectionIndex) - 1 {
let cellPath = NSIndexPath(forRow: rowIndex, inSection: sectionIndex)
let cell = tableView.cellForRowAtIndexPath(cellPath)
cell?.backgroundColor = UIColor(red:0.1451, green:0.1451, blue:0.1451, alpha:1.0)
}
}
for aLabel in labels {
aLabel.textColor = UIColor(red:0.6549, green:0.6549, blue:0.6549, alpha:1.0)
}
} else {
view.backgroundColor = UIColor.whiteColor()
tableView.backgroundColor = UIColor(red:0.9529, green:0.9529, blue:0.9529, alpha:1.0)
tableView.separatorColor = UIColor(red:0.7372, green:0.7371, blue:0.7372, alpha:1.0)
self.navigationController?.navigationBar.barTintColor = UIColor.whiteColor()
self.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.blackColor()]
self.navigationController?.navigationBar.tintColor = UIColor(red:0.9412, green:0.3412, blue:0.302, alpha:1.0)
for sectionIndex in 0...tableView.numberOfSections - 1 {
for rowIndex in 0...tableView.numberOfRowsInSection(sectionIndex) - 1 {
let cellPath = NSIndexPath(forRow: rowIndex, inSection: sectionIndex)
let cell = tableView.cellForRowAtIndexPath(cellPath)
cell?.backgroundColor = UIColor.whiteColor()
//do stuff with 'cell'
}
}
for aLabel in labels {
aLabel.textColor = UIColor.blackColor()
}
}
}
(此「設置」的tableView處於「tableviewController」,並在ContainerView嵌入)
你是如何控制/提供章節標題?你只是沒有對他們做任何事情。 – Wain
也,你有沒有確切的說您不滿意所以大家在這裏猜測是哪一部分? – Wain