기어가더라도 제대로

[UIKit-기초] ScrollView, blur, trnaslationX, fade-in, fade-out 본문

UIKit 기초

[UIKit-기초] ScrollView, blur, trnaslationX, fade-in, fade-out

Damagucci-juice 2022. 12. 13. 11:23
func scrollViewDidScroll(_ scrollView: UIScrollView) {
        guard let vc = vc else { return }
        let safeAreaTop = vc.view.safeAreaInsets.top
//        let magicalSafeAreaTop: CGFloat = safeAreaTop + (vc?.navigationController?.navigationBar.frame.height ?? 0)
//        let offset: CGFloat = magicalSafeAreaTop + scrollView.contentOffset.y
//        let alpha: CGFloat = 1 - (offset / magicalSafeAreaTop)
        let offset: CGFloat = safeAreaTop + scrollView.contentOffset.y
        let alpha: CGFloat = 1 - (offset / safeAreaTop)
        vc.ratingView.alpha = alpha
//        vc?.navigationController?.navigationBar.transform = .init(translationX: 0, y: min(0, -offset))
//        vc?.navigationController?.navigationBar.topItem?.titleView?.alpha = alpha
    }

 

출처

https://www.youtube.com/watch?v=F-L_AiAZ6ME&ab_channel=LetsBuildThatApp 

 

 

Comments