Search

네비게이션 바 fade animation

부제
카테고리
UIKit
세부 카테고리
애니메이션
Combine 카테고리
최종편집일
2022/09/20 08:10
작성중
관련된 포스팅
생성 일시
2022/07/16 14:40
태그
extension HomeViewController: UIScrollViewDelegate { func scrollViewDidScroll(_ scrollView: UIScrollView) { //스크롤뷰의 현재 위치 let offset = scrollView.contentOffset.y //MARK: 이미지 stick to top 애니메이션 if offset < 0 { slideShow.heightConstraint?.constant = 240 - offset headerTopConstraint.constant = offset } else { slideShow.heightConstraint?.constant = 240 } //MARK: 네비게이션 바 fade animation var proportionalOffset = offset / 60 if proportionalOffset > 1 { proportionalOffset = 1 let color = UIColor(red: 1, green: 1, blue: 1, alpha: proportionalOffset) self.navigationController?.navigationBar.tintColor = UIColor(hue: 1, saturation: 0, brightness: 1 - proportionalOffset, alpha: 1) self.navigationController?.navigationBar.backgroundColor = color UIApplication.statusBarBackgroundColor = color } else { let color = UIColor(red: 1, green: 1, blue: 1, alpha: proportionalOffset) self.navigationController?.navigationBar.tintColor = UIColor(hue: 1, saturation: 0, brightness: 1 - proportionalOffset, alpha: 1) self.navigationController?.navigationBar.backgroundColor = color UIApplication.statusBarBackgroundColor = color } } }
Swift
복사