Skip to content

Instantly share code, notes, and snippets.

@watura
Created April 2, 2019 21:25
Show Gist options
  • Save watura/d2f1abaf2848f52bb418707d0841cd95 to your computer and use it in GitHub Desktop.
Save watura/d2f1abaf2848f52bb418707d0841cd95 to your computer and use it in GitHub Desktop.
import UIKit
public class BoxedDisclosureCell: UITableViewCell, CellType {
var boxView: UIView!
func bind() {
if boxView.isNil {
boxView = UIView(frame: CGRect(x: 0, y: 0, width: 10, height: 10))
boxView.translatesAutoresizingMaskIntoConstraints = false
boxView.backgroundColor = UIColor.Zaim.colorBackgroundSub
boxView.layer.cornerRadius = 8
backgroundView = boxView
NSLayoutConstraint.activate([
boxView.topAnchor.constraint(equalTo: topAnchor, constant: 8),
boxView.leftAnchor.constraint(equalTo: leftAnchor, constant: 8),
rightAnchor.constraint(equalTo: boxView.rightAnchor, constant: 8),
bottomAnchor.constraint(equalTo: boxView.bottomAnchor, constant: 8),
boxView.heightAnchor.constraint(greaterThanOrEqualToConstant: 44)
])
}
textLabel?.text = "2019年4月2日"
boxView.layoutIfNeeded()
layoutIfNeeded()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment