ios - 有没有办法在 SwiftUI 中的动画之后执行函数?
问题描述
在 UIKit 中你可以这样做:
UIView.animate(withDuration: TimeInterval, animations: {
//animation
}) { (Bool) in
//code which will be executed after the animation
}
SwiftUI 中是否有类似的东西,或者你能想出一个替代品吗?
解决方案
这里描述了一种方法:
https://www.avanderlee.com/swiftui/withanimation-completion-callback/
该方法需要使用AnimatableModifier
协议的自定义实现。实现起来并非完全微不足道,但它似乎确实解决了问题。
推荐阅读
- javascript - Storybook 找不到某些故事
- python - 删除重复的熊猫仍然保留最后两行
- javascript - 在 React js 应用程序中使用 Keycloack 注销用户的问题
- php - 我无法在 PHP 中生成正确的 Json 文件
- java - 如何使用 Spring Boot 发送发布请求?
- reactjs - 如何在 React 中更改外部导入的 SVG 的颜色?
- python - 在 Python 中使用现有代码制作定义函数的建议
- android - 带有插图的 Android 导航栏和状态栏透明度
- javascript - 尝试使用 pdfjs 在 React 中渲染 base64。获取 CSS 错误
- python - 如何检测换行并拆分到不同的行