gpt4 book ai didi

ios - 如何为 ScrollView 设置动画?

转载 作者:行者123 更新时间:2023-11-28 23:34:41 26 4
gpt4 key购买 nike

如何在 ScrollView 中创建此类动画或自定义过渡。您可以在 GIF 中看到预期的动画:https://gfycat.com/EveryBackLhasaapso

期待:

在 ScrollView 上长按,它需要像gif动画一样展开,图标也需要放大。

我尝试使用 ScrollView 实现此目的,但动画与预期不匹配。

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}

最佳答案

现在运行您的应用程序。

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}

关于ios - 如何为 ScrollView 设置动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55356040/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com