Как мне оживить скроллвью? - PullRequest
0 голосов
/ 26 марта 2019

Как я могу создавать такие анимации или пользовательские переходы в виде прокрутки.Вы можете увидеть ожидаемую анимацию в GIF: https://gfycat.com/EveryBackLhasaapso

Ожидается:

При длительном нажатии на просмотре прокрутки, оно должно быть расширено, как анимация GIF, а значок также должен получить zoomin.

Я пытался добиться этого с помощью прокрутки, но анимация не соответствует ожидаемой.

UIView.animate(withDuration: 0.2, delay: 0.2, usingSpringWithDamping: 0.5, initialSpringVelocity: 1, options: .curveEaseInOut, animations: {
            self.scrollViewHeight.constant = isExpanded == true ? ViewConstants.collectionViewHeightWithExpand : ViewConstants.collectionViewHeightWithcollapse
            self.scrollContentViewHeight.constant = isExpanded == true ? ViewConstants.collectionViewHeightWithExpand : ViewConstants.collectionViewHeightWithcollapse
            self.scrollContentView.transform = isExpanded == true ? CGAffineTransform(scaleX: 1.20, y: 1.20) : CGAffineTransform.identity
             self.view.layoutIfNeeded()
        }) { _ in}

1 Ответ

1 голос
/ 26 марта 2019

Теперь запустите ваше приложение.

self.scrollViewHeight.constant = isExpanded == true ? ViewConstants.collectionViewHeightWithExpand : ViewConstants.collectionViewHeightWithcollapse
self.scrollContentViewHeight.constant = isExpanded == true ? ViewConstants.collectionViewHeightWithExpand : ViewConstants.collectionViewHeightWithcollapse

UIView.animate(withDuration: 0.2, delay: 0.2, usingSpringWithDamping: 0.5, initialSpringVelocity: 1, options: .curveEaseInOut, animations: {
             self.scrollContentView.transform = isExpanded == true ? CGAffineTransform(scaleX: 1.20, y: 1.20) : CGAffineTransform.identity
             self.view.layoutIfNeeded()
        }) { _ in}
...