设置页面背景色为 f2f2f7

This commit is contained in:
2026-07-12 16:01:08 +08:00
parent 34b26eedd6
commit bbff0c238d
3 changed files with 40 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
//
// Color+Hex.swift
// Note
//
// Created by fish on 2026/7/12.
//
import SwiftUI
extension Color {
init(hex: String) {
let trimmed = hex.trimmingCharacters(in: CharacterSet.alphanumerics.inverted)
var int: UInt64 = 0
Scanner(string: trimmed).scanHexInt64(&int)
let r, g, b: UInt64
switch trimmed.count {
case 6:
r = (int >> 16) & 0xFF
g = (int >> 8) & 0xFF
b = int & 0xFF
case 8:
r = (int >> 16) & 0xFF
g = (int >> 8) & 0xFF
b = int & 0xFF
default:
r = 0
g = 0
b = 0
}
self.init(
.sRGB,
red: Double(r) / 255,
green: Double(g) / 255,
blue: Double(b) / 255,
opacity: 1
)
}
}
+1
View File
@@ -39,6 +39,7 @@ struct FormatterView: View {
}
.padding()
.navigationTitle("文案格式化")
.background(Color(hex: "f2f2f7").ignoresSafeArea())
.navigationDestination(item: $resultText) { text in
ResultView(formattedText: text)
}
+1
View File
@@ -37,6 +37,7 @@ struct ResultView: View {
}
.navigationTitle("格式化结果")
.navigationBarTitleDisplayMode(.inline)
.background(Color(hex: "f2f2f7").ignoresSafeArea())
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
Button("完成") {