AIFeed

Compose Multiplatform 1.13.0 发布

AI summary

Compose Multiplatform 1.13.0 现已发布,改进了 iOS、Web 和桌面端的开发体验。亮点包括 SwiftUI 与 UIKit 中基于内容的自适应尺寸、WebGL 互操作性,以及通过 AppCDS 或 AOT 加快桌面端启动速度。

Translation(model translation, not the source's own text)

Compose Multiplatform 1.13.0 发布

Elvira Mustafina
Elvira Mustafina

Compose Multiplatform 1.13.0 现已发布,为 iOS、Web 和桌面开发体验带来了改进。以下是亮点内容:

  • SwiftUI 和 UIKit 中基于内容的尺寸计算
  • WebGL 互操作
  • 通过 AppCDS 或 AOT 加快桌面启动速度

想了解完整内容?请查看 Compose Multiplatform 1.13.0 新特性,或深入阅读 GitHub 上的发布说明。

开始使用 Compose Multiplatform

SwiftUI 和 UIKit 中基于内容的尺寸计算

嵌入 SwiftUI 和 UIKit 布局中的 Compose 视图现在可以根据可用空间报告其首选尺寸,从而让原生容器适应 Compose 内容。你可以将其用于动态内容,例如文本换行或控件展开,这样原生布局就能调整嵌入视图的尺寸,而不必依赖固定尺寸。

SwiftUI 和 UIKit 中 Compose Multiplatform 视图的基于内容的尺寸计算
SwiftUI 和 UIKit 中 Compose Multiplatform 视图的基于内容的尺寸计算

参见 SwiftUI 和 UIKit 的尺寸计算指南。

WebGL 互操作

想把自定义图形、着色器效果或 3D 场景带入你的 Web 应用?新的实验性 WebGL API 允许你使用与 Compose 共享的 WebGL 上下文绘制到纹理,并将结果直接显示在 Compose UI 旁边——包括来自 three.js 等 JavaScript 渲染器的内容。

WebGL 互操作
WebGL 互操作

探索 WebGL 互操作以了解更多。

通过 AppCDS 或 AOT 加快桌面启动速度

桌面应用现在可以通过 AppCDS 或提前编译(AOT)缓存更快启动。根据所选模式,你可以改善首次启动或后续启动的加载时间,并优化特定功能的首次使用。

例如,在一个小型演示应用上的基准测试显示,AotPrebuild 模式使冷启动速度提升高达 4.8 倍。在 build.gradle.kts 文件中通过 aot {} 块启用它:


        import org.jetbrains.compose.desktop.application.dsl.AotMode

compose.desktop {
    application {
        aot {
            mode = AotMode.AotPrebuild
        }
    }
}
      

了解有关通过 AppCDS 和 AOT 改善启动时间的更多信息。

Compose Multiplatform 1.13.0 还带来了来自 Jetpack Compose 1.13 的更新,包括迁移到基于状态的 BasicTextField,以及稳定的 FlexBox、Grid 和 LazyLayoutCacheWindow API。

准备好试一试了吗?更新你的依赖,探索新的 API,并告诉我们你对 Compose Multiplatform 1.13.0 的看法!

对于本文未涵盖的所有内容,请访问 Compose Multiplatform 1.13.0 新特性或完整发布说明。

订阅 Kotlin 博客更新

感谢,我们已收到!

The translation is machine-generated and individual terms may be off. Nothing is rewritten or cut; the original is authoritative.

Published by Kotlin Blog
This site only summarises and aggregates; copyright stays with the original author. Headlines and summaries follow the source — where they differ, the original wins.
Read the original ↗