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

IBとUIの適度な階層化の提案

naru-jpn
March 28, 2018

 IBとUIの適度な階層化の提案

IB上でUIの適度な階層化をすることによって、標準の仕組みでより簡単に扱えるような設計を目指しました。

naru-jpn

March 28, 2018
Tweet

More Decks by naru-jpn

Other Decks in Technology

Transcript

  1. class ApplicationStyle { static let isiPhone = UIDevice.current.userInterfaceIdiom == .phone

    class Category { static func TableViewCellRowHeight() -> CGFloat { if isiPhone { return 50.0 } else { return 60.0 } } …
  2. class FlattenViewController: UIViewController, Instantiatable { @IBOutlet weak var titleLabel: UILabel!

    @IBOutlet weak var messageLabel: UILabel! @IBOutlet weak var confirmLabel: UILabel! @IBOutlet weak var confirmButton: UIButton! @IBOutlet weak var notesButton: UIButton! @IBAction func onAcceptButtonClicked(sender: Any) { messageLabel.text = "͋Γ͕ͱ͏͍͟͝·ͨ͠" // ϨΠΞ΢τͷߋ৽... } }
  3. class LayeredViewController: UIViewController, Instantiatable { @IBOutlet weak var header: LayeredHeaderView!

    @IBOutlet weak var body: LayeredBodyView! @IBOutlet weak var footer: LayeredFooterView! } ֤ΧελϜϏϡʔͷ࡞Γํɺ࢖͍ํΛΈ͍͖ͯ·͠ΐ͏
  4. class LayeredHeaderView: UIView { @IBOutlet weak var titleLabel: UILabel! @IBOutlet

    weak var messageLabel: UILabel! /// ঝ୚͞Εͨ func accept() { messageLabel.text = "͋Γ͕ͱ͏͍͟͝·ͨ͠" } }
  5. class LayeredBodyView: UIView { @IBOutlet weak var messageLabel: UILabel! @IBOutlet

    weak var button: UIButton! @IBOutlet weak var zeroHeightConstraint: NSLayoutConstraint! /// ։ด var isOpen: Bool = true { didSet { zeroHeightConstraint.isActive = !isOpen } } }
  6. class LayeredViewController: UIViewController, Instantiatable { @IBOutlet weak var header: LayeredHeaderView!

    @IBOutlet weak var body: LayeredBodyView! @IBOutlet weak var footer: LayeredFooterView! @IBAction func onAcceptButtonClicked(sender: Any) { header.accept() body.isOpen = false } } 13ߦʂ