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
YesSQL, Process and Tooling at Scale
rocio
174
15k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.5k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
420
Between Models and Reality
mayunak
4
370
We Have a Design System, Now What?
morganepeng
55
8.2k
For a Future-Friendly Web
brad_frost
183
10k
The Language of Interfaces
destraynor
162
27k
Everyday Curiosity
cassininazir
0
260
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
3
1.1k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2k
From π to Pie charts
rasagy
0
240
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