2017-04-06 1 views
1

Ich versuche, die Farbe des Fokusstatus eines UITableViewCell festzulegen. Das Problem ist, dass ich einen seltsamen weißen Rand um die Zelle herum bemerkt habe. Also habe ich den Tabellenansichtshintergrund schwarz gemacht, und die Fokusfarbe auch schwarz, um zu überprüfen, ob das tatsächlich der Fall ist und man in der Screenshot sehen kann schwacher weiß/grauer Rand um die Zelle. Kann jemand das loswerden?Einstellen der Fokusfarbe von UITableViewCell

class MyCell: UITableViewCell { 

override func awakeFromNib() { 
    backgroundView = nil 
    backgroundColor = UIColor.clear 
} 

override func didUpdateFocus(in context: UIFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) { 
    super.didUpdateFocus(in: context, with: coordinator) 
    if context.nextFocusedView === self { 
     coordinator.addCoordinatedAnimations({ 
      self.contentView.backgroundColor = UIColor.black 
     }, completion: nil) 
    } 
    else { 
     coordinator.addCoordinatedAnimations({ 
      self.contentView.backgroundColor = UIColor.clear 
     }, completion: nil) 
    } 
} 

Wenn zwischen Zellen während der Scroll-Übergang enter image description here

Sehr schwache Linie umreißt die Zelle Very faint line outlining the cell

Antwort

0

in folgenden Code Versuchen

override func didUpdateFocus(in context: UIFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) { 
    super.didUpdateFocus(in: context, with: coordinator) 
    if context.nextFocusedView === self { 
     coordinator.addCoordinatedAnimations({ 
      self.contentView.backgroundColor = UIColor.black 
self.contentView.layer.borderColor = UIColor.black 
     }, completion: nil) 
    } 
    else { 
     coordinator.addCoordinatedAnimations({ 
      self.contentView.backgroundColor = UIColor.clear 
self.contentView.layer.borderColor = UIColor.clear 
     }, completion: nil) 
    } 
} 
+0

Das hat nicht funktioniert :(Wenn Sie schau dir den ersten Screenshot an, du wirst sehen, dass es eine graue Fokusfarbe gibt, bevor du dich zu Schwarz verwandelst. Ich denke, das ist, was ist durchschauen. und "sieht" wie eine Grenze aus. – dubdub

Verwandte Themen