Skip to content

Instantly share code, notes, and snippets.

@k-yamada
Last active May 23, 2018 06:39
Show Gist options
  • Save k-yamada/1ee518a097e22417c7b68ad24a6332dd to your computer and use it in GitHub Desktop.
Save k-yamada/1ee518a097e22417c7b68ad24a6332dd to your computer and use it in GitHub Desktop.
カスタムUITableViewCellの選択時の背景色を変更する ref: https://qiita.com/k-yamada-github/items/a589fca3b68847bc3a99
// CustomCell.swift:
import UIKit
class CustomCell: UITableViewCell {
override func awakeFromNib() {
super.awakeFromNib()
backgroundColor = UIColor(named: "primary")
selectedBackgroundView = makeSelectedBackgroundView()
}
private func makeSelectedBackgroundView() -> UIView {
let view = UIView()
view.backgroundColor = UIColor(named: "primary_light")
return view
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment