swiftui - 移动视图动画在模拟器上看起来超级迟钝,但在设备上很好
问题描述
我尝试在应用程序启动后将视图从屏幕中心动画到顶部:这在真实设备上看起来很好/符合预期,但在模拟器上超级慢(这不是由于 GIF):
有没有另一种/更好的方法来做那个动画?这种差异模拟器与设备的原因是什么?
这是示例项目:https ://github.com/haemi/StartingAnimations
struct ContentView: View {
@State private var alignment = Alignment.center
var body: some View {
ZStack(alignment: alignment) {
Color.white
.edgesIgnoringSafeArea(.all)
Text("Hello World")
}
.edgesIgnoringSafeArea(.bottom)
.onAppear(perform: onAppearAnimations)
}
private func onAppearAnimations() {
// withAnimation(Animation.easeOut(duration: 1)) { // not sluggish
withAnimation(Animation.easeOut(duration: 1).delay(1)) { // sluggish
alignment = .top
}
}
}
解决方案
推荐阅读
- reporting-services - 为什么我在 SQL Server Reporting Services 中收到错误“Invalid Class”?
- qt - QML - 第一个 TabButton 被 TabBar 剪裁
- python - 如何将 python 日期时间转换为 AWSTimestamp - appsync 标量类型?
- html - 使用 Python smtp 库组合纯字符串和 HTML 代码
- angular - Angular12 *ngIf 指令文本字段验证中的错误
- ruby-on-rails - {"..."} 的未定义方法 `model_name'
- parquet - 从 Python 增量编写 Parquet 数据集
- ruby-on-rails - 如何在没有关联数据库表的情况下为 ruby on rails 模块编写测试用例?
- ios - 无法解码 Firebase 云功能响应
- c++ - 通过套接字发送所有 argv