Created
November 20, 2015 14:35
-
-
Save mhpavl/f7819743027684b9e890 to your computer and use it in GitHub Desktop.
tvOS Settings-style table view cell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SettingCell: UITableViewCell { | |
@IBOutlet var customTextLabel: UILabel! | |
@IBOutlet var customDetailTextLabel: UILabel! | |
private let unfocusedBackgroundColor: UIColor? = UIColor(white: 1, alpha: 0.2) | |
override func awakeFromNib() { | |
super.awakeFromNib() | |
backgroundColor = unfocusedBackgroundColor | |
layer.cornerRadius = 5 | |
layer.masksToBounds = true | |
} | |
override func didUpdateFocusInContext(context: UIFocusUpdateContext, withAnimationCoordinator coordinator: UIFocusAnimationCoordinator) { | |
super.didUpdateFocusInContext(context, withAnimationCoordinator: coordinator) | |
coordinator.addCoordinatedAnimations({ | |
self.backgroundColor = self.focused ? UIColor.clearColor() : self.unfocusedBackgroundColor | |
self.layer.masksToBounds = !self.focused | |
}, completion: nil) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment