animation - SwiftUI 动画影响内部对象
问题描述
我有疑问..如果我有几个视图,里面有按钮等元素,并且在父视图上也有动画。我如何避免该动画影响内部对象。在我的情况下,所有按钮都会从父视图中捕获延迟。我尝试使用.сlipped,但我只对.shadow选项有帮助,对动画没有帮助;)
例子:
ViewA(editAction: {
}).opacity(isShow ? 1 : 0)
.animation(Animation.easeOut(duration: 0.6).delay(0.8))
ViewB(editAction: {
}).opacity(isShow ? 1 : 0)
.animation(Animation.easeOut(duration: 0.6).delay(0.95))
ViewC(editAction: {
}).opacity(isShow ? 1 : 0)
.animation(Animation.easeOut(duration: 0.6).delay(1.1))
ViewD(verified: .constant(true), editAction: {
}).opacity(isShow ? 1 : 0)
.animation(Animation.easeOut(duration: 0.6).delay(1.25))
ViewE(knowMoreAction: {
}).opacity(isShow ? 1 : 0)
.animation(Animation.easeOut(duration: 0.6).delay(1.4))
解决方案
将动画显式链接到依赖值,例如
ViewE(knowMoreAction: {
}).opacity(isShow ? 1 : 0)
.animation(Animation.easeOut(duration: 0.6).delay(1.4), value: isShow)
推荐阅读
- flutter - 如何在没有构建器的情况下将 Dart 模型类转换为列表?
- django - UndefinedError: 'url_for' 未定义;在 Django 中使用 Jinja2
- jsf - 如何在 blockUI 处于活动状态时禁用 p:defaultCommand?
- powershell - awk 从 bash 到 PowerShell
- react-native - 如何在 React Native 调试器中更改字体粗细?
- node.js - Nodejs,如何在返回 Promise 的异步迭代之间延迟执行
- android - androidTestImplementation Google Truth 1.0 和实现 Google Guava 27.0.1 无法满足的版本约束
- javascript - 如何使用过滤器更改原始数组?
- ios - 在 Siri 中提问后启动应用程序并显示提问结果
- python - Django charfield 正则表达式