认证|SignInWithAppleButton 组件的问题
了解 SignInWithAppleButton 组件在实践中存在的一些问题,以及解决方案。

SignInWithAppleButton
是 Authentication Services 框架中,提供用于快速即可 Apple 登录方式的 UI 组件。
但在实践中,它存在几个奇怪的问题 —— 我认为要么是 BUG,要么是与 SwiftUI 兼容性有待提升导致的问题。
无法根据 colorScheme 设置 signInWithAppleButtonStyle
SignInWithAppleButton
按钮的外观,不会随着系统外观(浅色/深色)的切换而自动更新:

如果使用通过 colorScheme
动态调整 signInWithAppleButtonStyle
,下面这个代码不会按照预期工作:

解决方案是:通过添加 id
强制视图刷新:
.id(colorScheme == .dark ? "dark-btn": "light-btn")

SignInWithAppleButton 会导致整个窗口背景色被覆盖
这个帖子遇到相同的问题:
Sign In With Apple Button stretche… | Apple Developer Forums