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

レイアウトを、もっと Swifty に(総集編)

Avatar for Elvis Shi Elvis Shi
March 28, 2018

レイアウトを、もっと Swifty に(総集編)

Avatar for Elvis Shi

Elvis Shi

March 28, 2018
Tweet

More Decks by Elvis Shi

Other Decks in Programming

Transcript

  1. var employedBy = "YUMEMI Inc." var job = "iOS Developer"

    var favoriteLanguage = "Swift" var twitter = "@lovee" var qiita = "lovee" var github = "el-hoshino" var additionalInfo = """ Ϛπμϩʔυελʔ͸͍͍ͧʂ """ class Me: Developable, Talkable { }
  2. CGRect ࡞Δͷ໘౗͡ΌΜʂ ▸ x, y, width, height Ͱ͔͠ઃఆͰ͖ͳ͍ ▸ "VUP

    -BZPVU ͳΒࠨӈͷ৔ॴͱ͔΋࢖͑Δ ▸ "VUP -BZPVU ͳΒଞͷϏϡʔͱͷҐஔؔ܎ͱ͔΋࢖͑Δ
  3. /PU"VUP-BZPVUΛ࢖ͬͨϨΠΞ΢τίʔυ public override func layoutSubviews() { super.layoutSubviews() // ...ུ... self.nal.layout(self.subTitleLabel)

    { $0 .pinTopLeft(to: self.mainTitleLabel, with: { $0.bottomLeft }) .pinRight(to: self.mainTitleLabel, with: { $0.right }) .setBottom(by: { $0.safeAreaGuide.bottom }) } } ٿطصعٛوطقپ⑦؃و٩٦ٸڋخٿطصعٛ
 猺؆د؊⯪⟓؞䐂נنڋٜٿطصعٛ猻
  4. /PU"VUP-BZPVUΛ࢖ͬͨϨΠΞ΢τίʔυ public override func layoutSubviews() { super.layoutSubviews() // ...ུ... self.nal.layout(self.subTitleLabel)

    { $0 .pinTopLeft(to: self.mainTitleLabel, with: { $0.bottomLeft }) .pinRight(to: self.mainTitleLabel, with: { $0.right }) .setBottom(by: { $0.safeAreaGuide.bottom }) } } PCN؃٠ڋٳٌ٭ڋٌخⓨا
  5. /PU"VUP-BZPVUΛ࢖ͬͨϨΠΞ΢τίʔυ public override func layoutSubviews() { super.layoutSubviews() // ...ུ... self.nal.layout(self.subTitleLabel)

    { $0 .pinTopLeft(to: self.mainTitleLabel, with: { $0.bottomLeft }) .pinRight(to: self.mainTitleLabel, with: { $0.right }) .setBottom(by: { $0.safeAreaGuide.bottom }) } } NC[QWV؃و٩٦ٸڋخ ٿطصعٛ
  6. /PU"VUP-BZPVUΛ࢖ͬͨϨΠΞ΢τίʔυ public override func layoutSubviews() { super.layoutSubviews() // ...ུ... self.nal.layout(self.subTitleLabel)

    { $0 .pinTopLeft(to: self.mainTitleLabel, with: { $0.bottomLeft }) .pinRight(to: self.mainTitleLabel, with: { $0.right }) .setBottom(by: { $0.safeAreaGuide.bottom }) } } ٿطصعٛ⻟彂 ؊و٩٦ٸڋ
  7. /PU"VUP-BZPVUΛ࢖ͬͨϨΠΞ΢τίʔυ public override func layoutSubviews() { super.layoutSubviews() // ...ུ... self.nal.layout(self.subTitleLabel)

    { $0 .pinTopLeft(to: self.mainTitleLabel, with: { $0.bottomLeft }) .pinRight(to: self.mainTitleLabel, with: { $0.right }) .setBottom(by: { $0.safeAreaGuide.bottom }) } } デ⃫猺6QR.GHV猻ֻ⛔䷐猺4KIJV猻؄⃬䷐猺$QVVQO猻 ؊⬕㔡خٴِٖٜٔغڋچ؃崎⹻
  8. /PU"VUP-BZPVUΛ࢖ͬͨϨΠΞ΢τίʔυ public override func layoutSubviews() { super.layoutSubviews() // ...ུ... self.nal.layout(self.subTitleLabel)

    { $0 .pinTopLeft(to: self.mainTitleLabel, with: { $0.bottomLeft }) .pinRight(to: self.mainTitleLabel, with: { $0.right }) .setBottom(by: { $0.safeAreaGuide.bottom }) } } デ⃫خOCKP6KVNG.CDGN؊デ⃬؇٧چ
  9. /PU"VUP-BZPVUΛ࢖ͬͨϨΠΞ΢τίʔυ public override func layoutSubviews() { super.layoutSubviews() // ...ུ... self.nal.layout(self.subTitleLabel)

    { $0 .pinTopLeft(to: self.mainTitleLabel, with: { $0.bottomLeft }) .pinRight(to: self.mainTitleLabel, with: { $0.right }) .setBottom(by: { $0.safeAreaGuide.bottom }) } } ⛔䷐خOCKP6KVNG.CDGN؊⛔䷐؇٧چ
  10. /PU"VUP-BZPVUΛ࢖ͬͨϨΠΞ΢τίʔυ public override func layoutSubviews() { super.layoutSubviews() // ...ུ... self.nal.layout(self.subTitleLabel)

    { $0 .pinTopLeft(to: self.mainTitleLabel, with: { $0.bottomLeft }) .pinRight(to: self.mainTitleLabel, with: { $0.right }) .setBottom(by: { $0.safeAreaGuide.bottom }) } } ⃬䷐خ岋؊َڋ٨ػٽص؊⃬䷐؇崎⹻
  11. /PU"VUP-BZPVUΛ࢖ͬͨϨΠΞ΢τίʔυ public override func layoutSubviews() { super.layoutSubviews() // ...ུ... self.nal.layout(self.subTitleLabel)

    { $0 .pinTopLeft(to: self.mainTitleLabel, with: { $0.bottomLeft }) .pinRight(to: self.mainTitleLabel, with: { $0.right }) .setBottom(by: { $0.safeAreaGuide.bottom }) } } ٿطصعٛخ∽اٴڋؾڋ
  12. /PU"VUP-BZPVUΛ࢖ͬͨϨΠΞ΢τίʔυ public override func layoutSubviews() { super.layoutSubviews() // ...ུ... self.nal.layout(self.subTitleLabel)

    { $0 .pinTopLeft(to: self.mainTitleLabel, with: { $0.bottomLeft }) .pinRight(to: self.mainTitleLabel, with: { $0.right }) .setBottom(by: { $0.safeAreaGuide.bottom }) } }
  13. /PU"VUP-BZPVUΛ࢖ͬͨϨΠΞ΢τίʔυ public override func layoutSubviews() { super.layoutSubviews() // ...ུ... self.nal.layout(self.subTitleLabel)

    { $0 .pinTopLeft(to: self.mainTitleLabel, with: { $0.bottomLeft }) .pinRight(to: self.mainTitleLabel, with: { $0.right }) } } Cannot convert value of type 'LayoutMaker<IndividualProperty.TopLeft.WillSetRightProperty>' (aka 'LayoutMaker<IndividualProperty.TopLeftRight>') to closure result type 'LayoutMaker<IndividualLayout>'
  14. /PU"VUP-BZPVUΛ࢖ͬͨϨΠΞ΢τίʔυ public override func layoutSubviews() { super.layoutSubviews() // ...ུ... self.nal.layout(self.subTitleLabel)

    { $0 .pinTopLeft(to: self.mainTitleLabel, with: { $0.bottomLeft }) .pinRight(to: self.mainTitleLabel, with: { $0.right }) .fitWidth() } } Type 'IndividualProperty.TopLeft.WillSetRightProperty' (aka 'IndividualProperty.TopLeftRight') does not conform to protocol 'LayoutPropertyCanStoreWidthType'
  15. O x y ࢛͍֯ྖҬΛ࡞Δʹ͸ ▸ ԣʹॏෳ͠ͳ͍ཁૉ ▸ ॎʹॏෳ͠ͳ͍ཁૉ ▸ ˞୺Ͱ͋Δඞཁ͸ͳ͍

    ▸ ྫ͑͹தԝͩͬͨΓɺ௕͞ ͩͬͨΓ΋0, ▸ ྫ͑͹CGRect(x, y, width, height)͸ԣʹ xͱwidthͷཁૉɺॎ ʹyͱheightͷཁૉ
  16. /PU"VUP-BZPVUΛ࢖ͬͨϨΠΞ΢τίʔυ public override func layoutSubviews() { super.layoutSubviews() // ...ུ... self.nal.layout(self.subTitleLabel)

    { $0 .pinTopLeft(to: self.mainTitleLabel, with: { $0.bottomLeft }) .pinRight(to: self.mainTitleLabel, with: { $0.right }) .setBottom(by: { $0.safeAreaGuide.bottom }) } } طٞيٶپٴڋؾڋ
 猺ؚ׼∶؞崎⹻ױب؂נ؆נ猻
  17. /PU"VUP-BZPVUΛ࢖ͬͨϨΠΞ΢τίʔυ public override func layoutSubviews() { super.layoutSubviews() // ...ུ... self.nal.layout(self.subTitleLabel)

    { $0 .pinTopLeft(to: self.mainTitleLabel, with: { $0.bottomLeft }) .pinRight(to: self.mainTitleLabel, with: { $0.right }) .setBottom(by: { $0.safeAreaGuide.bottom }) } } デ⃫崎⹻䃩؛ٴڋؾڋ
 猺㴋屢倁؇デ䷐ֻ儇屢倁؇⃫䷐ר崎⹻ױب׻猻
  18. /PU"VUP-BZPVUΛ࢖ͬͨϨΠΞ΢τίʔυ public override func layoutSubviews() { super.layoutSubviews() // ...ུ... self.nal.layout(self.subTitleLabel)

    { $0 .pinTopLeft(to: self.mainTitleLabel, with: { $0.bottomLeft }) .pinRight(to: self.mainTitleLabel, with: { $0.right }) .setBottom(by: { $0.safeAreaGuide.bottom }) } } デ⃫؄⛔崎⹻䃩؛ٴڋؾڋ
 猺㴋屢倁؇デ䷐؄⛔䷐ֻ儇屢倁؇⃫䷐ר崎⹻ױب׻猻
  19. /PU"VUP-BZPVUΛ࢖ͬͨϨΠΞ΢τίʔυ public override func layoutSubviews() { super.layoutSubviews() // ...ུ... self.nal.layout(self.subTitleLabel)

    { $0 .pinTopLeft(to: self.mainTitleLabel, with: { $0.bottomLeft }) .pinRight(to: self.mainTitleLabel, with: { $0.right }) .setBottom(by: { $0.safeAreaGuide.bottom }) } } ٨ٿڋٳ崎⹻䃩؛ٴڋؾڋ
 猺⑉؂؊㊦屢؆屢倁ר崎⹻ױب׻猻
  20. /PU"VUP-BZPVUΛ࢖ͬͨϨΠΞ΢τίʔυ public override func layoutSubviews() { super.layoutSubviews() // ...ུ... self.nal.layout(self.subTitleLabel)

    { $0 .pinTopLeft(to: self.mainTitleLabel, with: { $0.bottomLeft }) .pinRight(to: self.mainTitleLabel, with: { $0.right }) .setBottom(by: { $0.safeAreaGuide.bottom }) } } .C[QWV/CMGT+PKVKCN  .C[QWV/CMGT(TCOG 
 恘䎚؄倣䎚ר㽛ؚ׿؂מاقڀڋًٶڋ