๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐ŸŽ iOS

[iOS/Swift] UIViewControllerAnimatedTransitioning ์ •๋ฆฌ

by ํ‹ด๋”” 2023. 1. 29.
728x90
๋ฐ˜์‘ํ˜•
  • custom view controller transition ์„ ์œ„ํ•œ ํ”„๋กœํ† ์ฝœ
  • ๋ทฐ ์ปจํŠธ๋กค๋Ÿฌ์˜ ํ™”๋ฉด ์ „ํ™˜์„ ์œ„ํ•œ ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ๋งŒ๋“œ๋Š” animator ๊ฐ์ฒด๋ฅผ ์ •์˜ํ•  ์ˆ˜ ์žˆ์Œ
  • ์ธํ„ฐ๋ ‰ํ‹ฐ๋ธŒ ํŠธ๋žœ์ง€์…˜์„ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” animator ๊ฐ์ฒด๋ฅผ ํƒ€์ด๋ฐ์„ ์ œ์–ดํ•  ์ˆ˜ ์žˆ๋Š” ๋‹ค๋ฅธ ๊ฐ์ฒด์™€ ๊ฒฐํ•ฉํ•ด์•ผ ํ•จ
  • ์ด ํ”„๋กœํ† ์ฝœ์„ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ transitionDuration(using:), animateTransition(using:) ์„ ๊ตฌํ˜„ํ•ด์•ผ ํ•จ
  • UIViewControllerTransitioningDelegate ํ”„๋กœํ† ์ฝœ์„ ๋”ฐ๋ฅด๋Š” ๊ฐ์ฒด์—์„œ animator ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•จ
  • ๋ทฐ ์ปจํ‹€๋กค๋Ÿฌ ํ™”๋ฉด ์ „ํ™˜ ์‹œ presnet ํ•  ๊ฒฝ์šฐ UIModalPresentationStyle.custom์œผ๋กœ ์ง€์ •ํ•ด ์คŒ
  • animator๊ฐ์ฒด๋Š” UIViewControllerTransitioningDelegate์˜  transitioningDelegate๋ฅผ ์ง€์ •ํ•ด ์คŒ. transitionigDelegate๋กœ ๋ถ€ํ„ฐ animator๊ฐ์ฒด๋ฅผ ๋ฐ˜ํ™˜ ๋ฐ›๊ณ  ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ์ˆ˜ํ–‰ํ•จ
  • presenting, dismissing ๊ฐ๊ฐ ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ์ง€์ •ํ•  ์ˆ˜ ์žˆ์Œ(poping, pushing ๋งˆ์ฐฌ๊ฐ€์ง€)

 

transitionDuration(using:)

https://developer.apple.com/documentation/uikit/uiviewcontrolleranimatedtransitioning/1622032-transitionduration

  • ํ™”๋ฉด ์ „ํ™˜ ์‹œ๊ฐ„์„ ์ •์˜ํ•œ๋‹ค

 

animateTransition(using:)

https://developer.apple.com/documentation/uikit/uiviewcontrolleranimatedtransitioning/1622061-animatetransition

  • ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ์ •์˜ํ•จ
  • ํ™”๋ฉด ์ „ํ™˜์— ๊ด€๋ จ๋œ ์ •๋ณด๋Š” ์ปจํ…์ŠคํŠธ ํ˜•ํƒœ์˜ ๊ฐ์ฒด๋กœ ํ•ด๋‹น ๋ฉ”์†Œ๋“œ์— ์ „๋‹ฌ ๋จ
    • ์ด ์ •๋ณด๋ฅผ ์‚ฌ์šฉํ•ด์„œ ๋ทฐ ์ปจํ‹€๋กค๋Ÿฌ์˜ ๋ทฐ๋ฅผ ์ œ์–ดํ•˜๊ฒŒ ๋จ

 

  • ํ™”๋ฉด ์ „ํ™˜์— ์• ๋‹ˆ๋ฉ”์ด์…˜ ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ์‚ฌ์šฉ์ž์™€์˜ interaction์ด ๋“ค์–ด๊ฐ€์•ผ ํ•˜๋ฉด ์•„๋ž˜ ํ”„๋กœํ† ์ฝœ์„ ๊ตฌํ˜„ํ•ด์•ผ ํ•จ

 

728x90
๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€