Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- Git
- Swift
- iOS16
- error
- Archive
- Python
- stack
- 개발자
- JPA
- SwiftUI
- github
- rxswift
- Code
- Session
- MacOS
- Notification
- Realm
- mac
- IOS
- appstore
- FLUTTER
- 웹뷰
- String
- Xcode
- darkmode
- Apple
- Firebase
- 한글
- view
- UIButton
Archives
- Today
- Total
EEYatHo 앱 깎는 이야기
Swift ) iOS animate spring 효과넣기 - EEYatHo iOS 본문
iOS, Swift/Tip, Bug, Swift Error
Swift ) iOS animate spring 효과넣기 - EEYatHo iOS
EEYatHo 2021. 2. 19. 20:59반응형
여태껏 단순히 한방향으로 움직이고,
움직이는 속도를 조절하는 애니메이션만 알고있었다.
그런데 목표지점에 도착한 뒤, 살짝 튕기고 제자리로 돌아오는
일명 스프링 효과가 있었단걸 알았다.
usingSpringWithDamping
0.0 ~ 1.0
0.0에 가까울수록 심하게 튕기고, 1.0이면 튕기지 않는다
initialSpringVelocity
0.0 ~ 1.0
0.0에 가까울수록 튕길 때 속도가 빠르다
예시 )
UIView.animate(withDuration: 0.1, delay: 0, animations: {
// 일단 밑에 레이아웃하기 위한 버퍼 애니메이션
container.alpha = 1
},
completion: { _ in
UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 0.5, initialSpringVelocity: 0.5, options: .curveEaseInOut, animations: {
// 위로 올리기
container.snp.updateConstraints {
$0.bottom.equalToSuperview().offset(-20)
}
container.superview?.layoutIfNeeded()
},
completion: { _ in
UIView.animate(withDuration: 0.5, delay: 1, usingSpringWithDamping: 0.5, initialSpringVelocity: 0.5, options: .curveEaseInOut, animations: {
// 밑으로 내리기
container.snp.updateConstraints {
$0.bottom.equalToSuperview().offset(100)
}
container.superview?.layoutIfNeeded()
},
completion: { _ in
container.removeFromSuperview()
})
})
})
}
'iOS, Swift > Tip, Bug, Swift Error' 카테고리의 다른 글
Swift ) Background Foreground 감지 (0) | 2021.03.02 |
---|---|
Swift ) 내 앱 설정화면으로 이동하기 - EEYatHo iOS (0) | 2021.02.26 |
Swift ) UIButton 클릭시, 회색 되는거 없애기 - EEYatHo iOS (0) | 2021.02.25 |
Swift ) 네비게이션 바, 탭바 위에 팝업 띄우기 - EEYatHo iOS (0) | 2021.02.19 |
Swift ) SnapKit Animation ( AutoLayout, Animate ) (0) | 2021.02.18 |
Comments