Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
もっとFluidでRedirectableなモーダル表示アニメーション
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Kazuya Hirobe
September 13, 2018
500
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
もっとFluidでRedirectableなモーダル表示アニメーション
Kazuya Hirobe
September 13, 2018
More Decks by Kazuya Hirobe
See All by Kazuya Hirobe
iPhoneXのホームに戻るみたいなDissmisアニメーション
hirobe
0
1.5k
Featured
See All Featured
The Invisible Side of Design
smashingmag
301
52k
Are puppies a ranking factor?
jonoalderson
1
3.7k
Google's AI Overviews - The New Search
badams
0
1.1k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
Become a Pro
speakerdeck
PRO
31
6k
Tell your own story through comics
letsgokoyo
1
1k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.1k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
Testing 201, or: Great Expectations
jmmastey
46
8.2k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.1k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Writing Fast Ruby
sferik
630
63k
Transcript
ͬͱFluidͰ RedirectableͳϞʔμϧ දࣔΞχϝʔγϣϯ @hirobe 2018.9.13
ࣗݾհ ෦Ұ ( twitter : @hirobe ) גࣜձࣾBunguu iOSΞϓϦɺMacOSΞϓϦͷ։ൃΛͬͯ·͢ ࠓճͷιʔείʔυ:
https://github.com/hirobe/DismissFluidlySample
Designing Fluid Interfaces (WWDC 2018) • Fluid : ྲྀମͷɺͳΊΒ͔ͳ •
ӳޠ͔͚ͬͨ͠Ͳɺࠓࣈນ͋Δ https://developer.apple.com/videos/play/wwdc2018/803/
What makes an interface feed fluid? • ͳΊΒ͔ͳΠϯλϑΣʔεͬͯͲΜͳͩΖ͏ʁ • ৮ͬͯͬ͘͠Γ͘Δͷ
A tool feels like an extension of your mind •
৺ ମͷԆͷΑ͏ʹײ͡ΒΕΔಓ۩ • iPhoneखͰૢ࡞͢Δͷ • ͏·͘ಈ͚ਓؒͷExtensionͱͳΕΔ • ৮Δͷָ͕͘͠ͳΔ
಄ͷಇ͖ํʹΞϓϦͷԠΛ߹ΘͤΔ • Ԡ͕େࣄ • ࢥߟͷํసׂΓࠐΈʹରԠ͠·͠ΐ͏ • ۭؒతҰ؏ੑΛอͬͨஔΛ͠Α͏ • Ϣʔβͷ༧ଌʹԊͬͨදݱΛ͠Α͏ •
খ͞ͳλονૢ࡞Ͱେ͖ͳग़ྗΛ͠Α͏ • εΫϩʔϧͷڥքʹόϯυΛ͚ͭΑ͏ • ΞχϝʔγϣϯͷνϥπΩΛࢭ͠Α͏
Redirectable • ࢥߟͷํసׂΓࠐΈʹଈԠ͠·͠ΐ͏ ਓؒߟ͑ͳ͕Βը໘ૢ࡞͢Δ • δΣενϟதͷδΣενϟΛՄೳʹ͠Α͏
δΣενϟதͷδΣενϟ iPhoneX • ϗʔϜʹΓͳ͕Β ϗʔϜը໘ΛԣεϫΠϓ
δΣενϟதͷδΣενϟ iPhoneX • ΞϓϦΛλοϓͯ͠ ֦େதʹϗʔϜը໘ʹΔ
δΣενϟதͷδΣενϟ iPhoneX • ΞϓϦΛىಈͯ͠ ֦େதʹΞϓϦΛૢ࡞
ΞϓϦͰ࣮͍ͨ͠ʂ • Ͳ͜Ͱ͑ΔͩΖ͏͔ʁ • ͦ͏͍͑ࢥ͍ͨΔ͜ͱ͕
ࣸਅΛλοϓ͢Δͱ֦େදࣔ͢ΔΞϓϦ
λον͕ແࢹ͞ΕΔ͜ͱ͕͋Δ • ࢠը໘Λดͨ͡ޙʹɺ ผͷը૾Λ։͖͍ͨ • ը૾ͷॖখΞχϝʔγϣ ϯ͕ऴΘΔલʹλοϓ͠ ͪΌͬͯΔʁʁ /P 3FTQPOTF
iPhoneXͷϗʔϜͷ߹
iPhoneXͷϗʔϜͷ߹ • ΞϓϦΛด͍ͯΔؒɺ λονΛͪΌΜͱड͚͚ͯ ͘ΕΔ -> Fluid!
ը໘Λด͡ΔભҠதʹ ผૢ࡞Λ ड͚͚ΔͷΛ ΞϓϦͰ࣮ݱ͢Δͧ
UIViewControllerAnimatedTransitioning • containerViewʹదʹviewΛషΓ͚ͯ ը໘ભҠΞχϝʔγϣϯΛॻ͍͓ͯ͘ Ξχϝʔγϣϯ༻ͷ View containerView ը໘
UIViewControllerAnimatedTransitioning • ç func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { if isForPresented
{ // present presentAnimation(transitionContext) } else { // dissmis dissmisAnimation(transitionContext) } } func dissmisAnimation(_ transitionContext: UIViewControllerContextTransitioning) { let containerView = transitionContext.containerView guard let nav = transitionContext.viewController(forKey: .from) as? UINavigationController, let detailVC:DetailViewController = nav.visibleViewController as? DetailViewController else { fatalError() }
UIViewControllerAnimatedTransitioning • ç let fromImageRect = detailVC.detailImageRect(containerView: containerView, safeAreaInsets: from?.view?.safeAreaInsets
?? .zero) let toImageRect = detailVC.parentImageViewRect // imageΛҠಈ͢ΔͨΊͷviewΛ࡞ let imageView:UIImageView = UIImageView(frame: fromImageRect) imageView.contentMode = .scaleAspectFill imageView.clipsToBounds = true imageView.image = detailVC.parentImage containerView.addSubview(imageView) // ॖখΞχϝʔγϣϯ nav.view.isHidden = true UIView.animate(withDuration: transitionDuration(using: transitionContext), delay: 0, options: [.curveEaseInOut], animations: { () -> Void in imageView.frame = toImageRect }) { (finished) -> Void in nav.view.removeFromSuperview() transitionContext.completeTransition(true) } }
ࢦΛͨ͠ޙͷΞχϝʔγϣϯ • UIViewControllerTransitionDelegate, UIViewControllerAnimatedTransitioningΛ࣮ • ։࣌͘ʹtransitionDelegateʹηοτ override func collectionView(_ collectionView:
UICollectionView, didSelectItemAt indexPath: IndexPath) { : let storyboard = UIStoryboard(name: "Main", bundle: nil) guard let vc = storyboard.instantiateViewController(withIdentifier: "DetailViewController") as? DetailViewController else { return } let nav = UINavigationController(rootViewController: vc) nav.isNavigationBarHidden = true nav.modalPresentationStyle = .custom nav.transitioningDelegate = vc.modalTransition self.present(nav, animated: true) }
• dismiss(animated: true)ͰΞχϝʔγϣϯΛ։࢝ • λονδΣενϟ͕ແࢹ͞ΕΔ εϫΠϓɺϘλϯૢ࡞ ࢦΛͨ͠:dismiss(animated: true) ด͡ΔΞχϝʔγϣϯ UIViewController
AnimatedTransitioning UIViewControllerAnimatedTransitioning
UIAnimatedTransitioningΛΘͳ͍ ->ࢦΛͨ͠ޙɺભҠઌ͕Ξχϝʔγϣϯ εϫΠϓɺϘλϯૢ࡞ ࢦΛͨ͠: dismiss(animated: false) ࢠViewCotroller ด͡ΔΞχϝʔγϣϯ ʢ৮ΕΔʣ ViewCotroller
λοϓ͕ແࢹ͞Εͳ͘ͳͬͨ • Ͱ͖ͨʂ
͚ͩͲɺɺ
FatͳViewControllerʹͳΔ ΑͶ →ͳΜͱ͔͍ͨ͠ ͚ͩͲɺɺ
UIViewControllerAnimatedTransitioningΛ ྲྀ༻͠Α͏ class DetailModalTransition : NSObject, UIViewControllerTransitioningDelegate, UIViewControllerAnimatedTransitioning { func
animateTransition(using transitionContext: UIViewControllerContextTransitioning) { if isForPresented { // present // : } else { // dissmis self.dissmisAnimation( containerView: transitionContext.containerView, from: transitionContext.viewController(forKey: .from), to: transitionContext.viewController(forKey: .to), duration: self.transitionDuration(using: transitionContext), completeTransition: transitionContext.completeTransition) } } func dissmisAnimation(containerView: UIView, from: UIViewController?, to: UIViewController?, duration: TimeInterval, completeTransition: @escaping (_ didComplete: Bool) -> Void) { // ΞχϝʔγϣϯΛॻ͘ } }
extension DetailModalTransition { func dissmisFluidly(viewController:UIViewController?) { guard let parent =
viewController?.presentingViewController, let child = parent.presentedViewController, let window = parent.view?.window else { return } viewController?.dismiss(animated: false) { // viewDidDisappearͷޙʹݺΕΔͷͰҙ let containerView = UIView(frame: window.bounds) containerView.isUserInteractionEnabled = false window.addSubview(containerView) self.dissmisAnimation(containerView: containerView, from: child, to: parent, duration: 0.6, completeTransition: { didComplete in containerView.removeFromSuperview() }) } } } UIViewControllerAnimatedTransitioningΛ ྲྀ༻͠Α͏
·ͱΊ • ը໘ભҠΞχϝʔγϣϯதʹλονΛ༗ޮʹͨ͠ • ࢦΛͨ͠ޙɺભҠઌͷViewControllerͰॲཧ͢Δ • λον͕ແࢹ͞Εͳ͘ͳͬͨ • Fluidʹͳͬͨʂʂ •
͏ͪΐͬͱεϚʔτͳΓํͳ͍ͷ͔ Github : https://github.com/hirobe/DismissFluidlySample