
- 修改Package.swift以支持iOS 15和macOS 12。 - 更新swift-tca-architecture-guidelines.mdc中的alwaysApply设置为false。 - 注释掉AppDelegate中的NIMSDK导入,移除不再使用的NIMConfigurationManager和NIMSessionManager文件。 - 添加新的API相关文件,包括EMailLoginFeature、IDLoginFeature和相关视图,增强登录功能。 - 更新APIConstants和APIEndpoints以反映新的API路径。 - 添加本地化支持文件,包含英文和中文简体的本地化字符串。 - 新增字体管理和安全工具类,支持AES和DES加密。 - 更新Xcode项目配置,调整版本号和启动画面设置。
54 lines
1.7 KiB
Swift
54 lines
1.7 KiB
Swift
import SwiftUI
|
||
|
||
/// ScreenAdapter 使用示例
|
||
/// 展示如何在 SwiftUI 视图中使用屏幕适配工具类
|
||
struct ScreenAdapterExample: View {
|
||
var body: some View {
|
||
GeometryReader { geometry in
|
||
VStack(spacing: 20) {
|
||
|
||
// 方法1: 直接使用 ScreenAdapter 静态方法
|
||
Text("方法1: 直接调用")
|
||
.font(.system(size: ScreenAdapter.fontSize(16, for: geometry.size.width)))
|
||
.padding(.leading, ScreenAdapter.width(20, for: geometry.size.width))
|
||
.padding(.top, ScreenAdapter.height(50, for: geometry.size.height))
|
||
|
||
// 方法2: 使用 View Extension (推荐)
|
||
Text("方法2: View Extension")
|
||
.adaptedFont(16)
|
||
.adaptedHeight(50)
|
||
|
||
// 方法3: 使用比例计算
|
||
Text("方法3: 比例计算")
|
||
.font(.system(size: 16 * ScreenAdapter.widthRatio(for: geometry.size.width)))
|
||
.padding(.top, 50 * ScreenAdapter.heightRatio(for: geometry.size.height))
|
||
|
||
Spacer()
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
// MARK: - 使用建议
|
||
/*
|
||
|
||
推荐使用顺序:
|
||
|
||
1. View Extension (最简洁)
|
||
.adaptedFont(16)
|
||
.adaptedHeight(20)
|
||
.adaptedWidth(100)
|
||
|
||
2. 直接调用静态方法 (灵活性高)
|
||
.font(.system(size: ScreenAdapter.fontSize(16, for: geometry.size.width)))
|
||
.padding(.top, ScreenAdapter.height(20, for: geometry.size.height))
|
||
|
||
3. 比例计算 (自定义场景)
|
||
let ratio = ScreenAdapter.heightRatio(for: geometry.size.height)
|
||
.padding(.top, 20 * ratio)
|
||
|
||
*/
|
||
|
||
#Preview {
|
||
ScreenAdapterExample()
|
||
} |