On page 45, we override awakeFromNib()
in the SearchResultCell
class in order to customize the cell selection color:
override func awakeFromNib() {
super.awakeFromNib()
let selectedView = UIView(frame: CGRect.zero)
selectedView.backgroundColor = UIColor(red: 20/255, green: 160/255, blue: 160/255, alpha: 0.5)
selectedBackgroundView = selectedView
}
What I find confusing is the use of CGRect.zero
, which seems to indicate that we’re creating a UIView with a size of zero, located at the (0, 0) coordinate within its superview. How is it that this new view covers the entire cell, then? Is this something that the selectedBackgroundView
property handles on its own?