Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Readable Width in action

Readable Width in action

Tomohiro Nishimura

October 26, 2016
Tweet

More Decks by Tomohiro Nishimura

Other Decks in Programming

Transcript

  1. ಺༰ w جຊ w 6*5BCMF w #BTJD$FMM w $VTUPN$FMM w

    8JUI"DDFTTPSZ7JFX w ίʔυ͔Βࢦఆ͢Δ
  2. ಺༰ w جຊ w 6*5BCMF w #BTJD$FMM w $VTUPN$FMM w

    8JUI"DDFTTPSZ7JFX w ίʔυ͔Βࢦఆ͢Δ
  3. ಺༰ w جຊ w 6*5BCMF w #BTJD$FMM w $VTUPN$FMM w

    8JUI"DDFTTPSZ7JFX w ίʔυ͔Βࢦఆ͢Δ
  4. DFMM-BZPVU.BSHJOT'PMM PX3FBEBCMF8JEUI class TableViewController: UITableViewController { override func viewDidLoad() {

    super.viewDidLoad() tableView.cellLayoutMarginsFollowReadableWidth = true } }
  5. ಺༰ w جຊ w 6*5BCMF w #BTJD$FMM w $VTUPN$FMM w

    8JUI"DDFTTPSZ7JFX w ίʔυ͔Βࢦఆ͢Δ
  6. DFMM-BZPVU.BSHJOT'PMM PX3FBEBCMF8JEUI class TableViewController: UITableViewController { override func viewDidLoad() {

    super.viewDidLoad() tableView.cellLayoutMarginsFollowReadableWidth = true } }
  7. ಺༰ w جຊ w 6*5BCMF w #BTJD$FMM w $VTUPN$FMM w

    8JUI"DDFTTPSZ7JFX w ίʔυ͔Βࢦఆ͢Δ
  8. ಺༰ w جຊ w 6*5BCMF w #BTJD$FMM w $VTUPN$FMM w

    8JUIBDDFTTPSZWJFX w ίʔυ͔Βࢦఆ͢Δ
  9. private func setup() { label = UILabel() label.text = "Section

    Header" label.font = UIFont.boldSystemFont(ofSize: 15) contentView.addSubview(label) } override func layoutSubviews() { super.layoutSubviews() label.sizeToFit() let insetY = (bounds.height - label.bounds.height) / 2 label.frame = bounds.insetBy(dx: 16, dy: insetY) }
  10. private func setup() { label = UILabel() label.text = "Section

    Header" label.font = UIFont.boldSystemFont(ofSize: 15) label.translatesAutoresizingMaskIntoConstraints = false contentView.addSubview(label) let guide = contentView.readableContentGuide NSLayoutConstraint.activate([ label.topAnchor.constraint(equalTo: guide.topAnchor), label.bottomAnchor.constraint(equalTo: guide.bottomAnchor), label.leadingAnchor.constraint(equalTo: guide.leadingAnchor), label.trailingAnchor.constraint(equalTo: guide.trailingAnchor), ]) }