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

Swift愛好会合宿 in 笹川

53e2d354b3299d64a54af680865516d5?s=47 Sato Takeshi
December 04, 2016

Swift愛好会合宿 in 笹川

【1周年・合宿】集まれSwift好き!Swift愛好会 vol13
https://love-swift.connpass.com/event/43865/
の発表資料です。
カスタムトランジションを作りました。

53e2d354b3299d64a54af680865516d5?s=128

Sato Takeshi

December 04, 2016
Tweet

Transcript

  1. SwiftѪ޷ձ߹॓ in ࡫઒ 2016೥12݄4೔ Swiftϓϩάϥϛϯάษڧձ 2016/11/10 1

  2. UIτϨʔεձͱ͍͏ษڧձΛͯ͠·͢ https://ios-app-developers.connpass.com/event/44867/ Swiftϓϩάϥϛϯάษڧձ 2016/11/10 2

  3. ͍͍ΞϓϦͷUIΛਅࣅͯ͠ɺΈΜͳͷ UI։ൃٕज़ΛΞοϓͤ͞Δษڧձ Swiftϓϩάϥϛϯάษڧձ 2016/11/10 3

  4. 11݄-12݄ͷ͓୊ GohobeeΞϓϦͷ͝๙ඒը໘Λਅࣅ͢Δ Swiftϓϩάϥϛϯάษڧձ 2016/11/10 4

  5. Gohobeeͷ͝๙ඒը໘ Swiftϓϩάϥϛϯάษڧձ 2016/11/10 5

  6. • ͦΕͧΕҟͳΔηϧϨΠΞ΢τ • γʔϜϨεʹ࣍ͷը૾͕ભҠ • ભҠޙը૾͕͘Δ͘ΔΞχϝʔγϣϯ • ύϥϥοΫεεΫϩʔϧ Swiftϓϩάϥϛϯάษڧձ 2016/11/10

    6
  7. ͱͬͯ΋ڽ͍ͬͯΔ (´ʀωʀʆ) Swiftϓϩάϥϛϯάษڧձ 2016/11/10 7

  8. ͲΜͳ࢓ࣄͰ΋ɺे෼ʹখ͘͞෼ׂ͢ Ε͹ඞͣย͚ͮΔ͜ͱ͕Ͱ͖Δɻ ϔϯϦʔɾϑΥʔυ Swiftϓϩάϥϛϯάษڧձ 2016/11/10 8

  9. γʔϜϨεʹ࣍ͷը૾͕ભҠ ͚ͩ͜͜ؤுΔʂ Swiftϓϩάϥϛϯάษڧձ 2016/11/10 9

  10. ࡞ͬͨ https://github.com/SatoTakeshiX/SwiftSharedViewTransition Swiftϓϩάϥϛϯάษڧձ 2016/11/10 10

  11. ͜Μͳײ͡ Swiftϓϩάϥϛϯάษڧձ 2016/11/10 11

  12. ࢓૊Έ 1. UIViewControllerAnimatedTransitioningΛదԠͨ͠ΫϥεΛ ࡞Δɻ͜ͷΫϥεͰΞχϝʔγϣϯΛࢦఆ͢Δ 2. UINavigationControllerͷαϒΫϥεΛ࡞ͬͯɺ UINavigationControllerDelegateʹదԠͤ͞Δɻ *navigationController(_:animationControllerFor:from:to:)ϝ ιουΛ࣮૷ɻ1ͷΠϯελϯεΛฦ͢ Swiftϓϩάϥϛϯάษڧձ

    2016/11/10 12
  13. ؆୯ʁ Swiftϓϩάϥϛϯάษڧձ 2016/11/10 13

  14. UIViewControllerAnimatedTransitioningͷඞਢϝιου • transitionDuration(using:) • Ξχϝʔγϣϯ࣌ؒΛࢦఆ • animateTransition(using:) • Ξχϝʔγϣϯํ๏Λࢦఆ Swiftϓϩάϥϛϯάษڧձ

    2016/11/10 14
  15. ϋϚϦϙΠϯτ • frameࢦఆ͸UIViewͷίϯόʔτΛ࢖͏ɻ func createImageView() -> UIImageView? { guard let

    detailImageView = self.imageView else { return nil } let imageView = UIImageView(image: self.image) imageView.contentMode = .scaleAspectFill imageView.frame = detailImageView.convert(detailImageView.frame, to: self.view) //imageView.frame = detailImageView.frame <-͜Ε͸ͩΊɻ return imageView } Swiftϓϩάϥϛϯάษڧձ 2016/11/10 15
  16. • ը૾ੵΈॏͳΔ໰୊ Swiftϓϩάϥϛϯάษڧձ 2016/11/10 16

  17. ίϯςφϏϡʔ͸ભҠ͢Δͨͼʹಉ͡ΠϯελϯεΛ͍࣋ͬͯ Δɻ ίϯςφϏϡʔͷaddSubViewͨ͠ΒޙͰফ͞ͳ͍ͱ͍͚ͳ͍ Swiftϓϩάϥϛϯάษڧձ 2016/11/10 17

  18. ࠷ॳʹίϯςφϏϡʔͷαϒϏϡʔʹରͯ͠ɺ removeFromSuperview()ͯ͠ରԠͨ͠ //pop࣌ͷΞχϝʔγϣϯ fileprivate func backwardTransition(_ transitionContext: UIViewControllerContextTransitioning) { //

    PushͱٯͷΞχϝʔγϣϯ guard let fromeVC = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from) else { return } guard let toVC = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to) else { return } let containerView = transitionContext.containerView //લճભҠ͍ͨ͠͞ͷImageView͕࢒͍ͬͯΔͷͰҰ౓શͯΛ֎͢ containerView.subviews.forEach { view in view.removeFromSuperview() } Swiftϓϩάϥϛϯάษڧձ 2016/11/10 18
  19. ·ͩ࢒ͬͯΔ໰୊ɻ ໭Δͱ͖ʹίϨΫγϣϯϏϡʔͷηϧʹ্ख͘ೖΒͳ͍ɻ ΧΫͬͯͳΔ ->12/8ͷUIτϨʔεձ·ͰʹؤுΔʂ௚͢ʂ Swiftϓϩάϥϛϯάษڧձ 2016/11/10 19

  20. ιʔε https://github.com/SatoTakeshiX/SwiftSharedViewTransition Swiftϓϩάϥϛϯάษڧձ 2016/11/10 20