Skip to content

Instantly share code, notes, and snippets.

@grifas
Last active September 17, 2018 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grifas/c1c8537949cae482db1c2918d1232882 to your computer and use it in GitHub Desktop.
Save grifas/c1c8537949cae482db1c2918d1232882 to your computer and use it in GitHub Desktop.
UITableViewCell with a self sizing accessory view
class MyCell: UITableViewCell {
init() {
// Initialize...
accessoryView = UIView()
accessoryView?.translatesAutoresizingMaskIntoConstraints = false
addSubview(accessoryView!)
// With SnapKit
accessoryView?.snp.makeConstraints({ make in
make.centerY.equalToSuperview()
make.right.equalToSuperview().inset(16)
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment