Ray Wenderlich/Core Animation
-
[CoreAnimation] Ch11. Layer Springs (레이어단의 스프링 애니메이션) + (CASpringAnimation)Ray Wenderlich/Core Animation 2018. 8. 9. 20:14
IntroLayer에 스프링을 적용하는 건 UIView에서 적용하던 것과 조금 다르다. UIView에서 사용했던건 간략화된 유사-스프링 애니메이션이라고 볼 수 있다. 하지만 Layer에서 사용하는 스프링은 물리적인 접근을 통해 좀 더 실제 스프링효과를 보여준다. Damped harmonic oscillators(시간이 지남에 따라 진폭이 감소하는 진동을 말함) 실에 매달린 추를 swing시킨다고 생각해보자(물리시간에 진자운동이라고 배웠던 기억이..)마찰이 없다면, 무한히 추가 왔다갔다 할 것이다. (Harmonic oscillator) 하지만 실제로는 마찰이 있져?? 이때는 추가 왔다 갔다 하면서 멈추게 된다. 왔다 갔다 하는 거리도 시간이 지남에 따라 줄어들게 된다. (Damped harmonic os..
-
[CoreAnimation] Ch10. Groups and Advanced Timing (애니메이션 그룹과 커스텀 타이밍)Ray Wenderlich/Core Animation 2018. 8. 8. 00:16
Intro지금까지 layer animation을 전부 independent하게 추가하였다.하지만 여러 애니메이션을 syncronous하게 할 수 있다. 이게 바로 animation groups이다. CAAnimationGroupCAAnimationGroup는 CAAnimation을 상속받는다. 즉, 우리가 지금까지 사용했던 CABasicAnimation의 모든 프로퍼티가 사용가능하다. beginTime, duration, fillMode 등 AnimationGroup에서 설정한 beginTime, duraiton, fillMode등은 그룹에 속한 애니메이션 객체에 적용된다. 따라서, 그룹에 추가할 애니메이션을 설정할 때, 굳이 위 값들을 설정해주지 않아도 알아서 적용된다.Animation easingUI..
-
[CoreAnimation] Ch9. Animation Keys and Delegates (레이어 애니메이션 Delegate, Key를 사용하기)Ray Wenderlich/Core Animation 2018. 8. 1. 20:58
9장 Animation Keys and Delegates Intro UIView animation을 사용할 때, 애니메이션을 중지할 수 없었다. 하지만 Core Animation에선 모든게 가능!layer의 애니메이션은 멈출 수 있다. 더불어 delegate를 설정하여 애니메이션의 시작과 끝(or interrupted)에 대한 핸들링도 가능하다. Introducing animation delegates CAAnimationDelegate에는 두 메소드가 있다. func animationDidStart(_ anim: CAAnimation)func animationDidStop(_ anim: CAAnimation, finished flag: Bool) Key-value coding compliance CAA..
-
[CoreAnimation] Ch8. Getting started with Layer Animations. (레이어 애니메이션)Ray Wenderlich/Core Animation 2018. 7. 31. 22:20
8장 Getting Started with Layer Animations Section 3. Layer AnimationsView vs LayerLayer는 View와 다르다. Layer는 View를 표현하는데 필요한 데이터를 갖는 모델 객체다. Layer는 View와 어떻게 다른가?- 말 그대로 모델 객체! 데이터만 포함한다. 뷰의 로직에는 전혀 관여하지 않는다. 오토레이아웃 의존성이나 사용자 인터렉션에도 물론 관여하지 않는다.- View에 없는 visible trait가 존재한다. borderLine, borderColor, position, shadow 등- GPU는 레이어 정보를 캐싱하여, 화면에 그림을 그린다. Layer, View. 다시 한 번 비교Views- 복잡한 뷰 계층 구조를 갖는다. ..
-
[CoreAnimation] Ch7. Animating Constraints - (오토레이아웃으로 애니메이션하기)Ray Wenderlich/Core Animation 2018. 7. 31. 22:12
7장 Animating ConstraintsIntro이전에는 alpha, frame등의 변경으로 애니메이션을 구현했지만, AutoLayout은 좀 다르다.Constraint의 변경을 한 뒤, AutoLayout의 State변경을 통해 애니메이션을 구현한다. Making the menu expandNSLayoutConstraint도 UIView처럼 @IBOutlet으로 연결가능하다.연결한 Constraint의 constant를 변경해보자.뷰의 크기와 위치가 변하는걸 확인한다. 이제 애니메이션을 해보자. Animating layout changesConstraint의 constant를 변경하고 끝내면 애니메이션 없이 뷰가 변한다.하지만 여기에 UIView.animate(.... view.layoutIfNee..