// // View+Style.swift // IOS_study // // Created by CC-star on 2025/6/12. // import SwiftUI extension View{ func btnStyle() -> some View{ size15().buttonStyle(.borderless).accent() } func textStyle() -> some View{ size15().tc().lineSpacing(6) } func textStyle2() -> some View{ size15().tc2().lineSpacing(6) } func oneLineStyleMiddle() -> some View{lineLimit(1).truncationMode(.middle)} //List里面的东西 func subTStyle() -> some View{ size16semib().tc() } func subTStyleL() -> some View{ headline().tc() } //cell func cellPaddingRadius() -> some View{//带radius padding(.vertical) .padding(.horizontal,12) .bg() .radius(8) } func cellOutPadding() -> some View{ padding([.top,.horizontal],9) //.padding(.bottom,10) } //list func listRowStyle() -> some View{ listRowInsets(EdgeInsets()) .listRowSeparator(.hidden) .listRowBackground(Color.clear) } func listStyle() -> some View{ listStyle(.inset) .scrollContentBackground(.hidden) .bg2() .environment(\.defaultMinListRowHeight,0) } //总的 func cellStyle() -> some View{ cellPaddingRadius().cellOutPadding().listRowStyle() } //Form里面的 func littleTStyle() -> some View{ size13().tc2().fontWeight(.light) } func pStyle() -> some View{ frame(height: kTFAndPHeight).border(borderColor: Color(.systemGray4)) } func tfStyle() -> some View{ frame(height: kTFAndPHeight).padding(.horizontal,9).border(borderColor: Color(.systemGray4)).submitLabel(.done) } func tfStyleMultiS() -> some View{ lineLimit(1...4).frame(minHeight: kTFAndPHeight).padding(.horizontal,9).border(borderColor: Color(.systemGray4)).lineSpacing(4) .fixedSize(horizontal: false, vertical: true) } func tfStyleMultiM() -> some View{ lineLimit(3...8).frame(minHeight: kTFAndPHeight).padding(.horizontal,9).border(borderColor: Color(.systemGray4)).lineSpacing(4) .fixedSize(horizontal: false, vertical: true) } func tfStyleMultiL() -> some View{ lineLimit(4...10).frame(minHeight: kTFAndPHeight).padding(.horizontal,9).border(borderColor: Color(.systemGray4)).lineSpacing(4) .fixedSize(horizontal: false, vertical: true) } func conlonStyle() -> some View{ bold().padding(.horizontal,2).offset(y: -1) } func toggleStyle(isTap: Bool) -> some View{ size15().foregroundStyle(isTap ? .white : .aTC).padding(.horizontal,10).frame(height: kTFAndPHeight) .background(isTap ? Color.accent.gradient : Color.bg.gradient).radius() .border(borderColor: isTap ? .clear : .accent) } func appleStyle() -> some View{ headline().white().frame(height: 55).frame(maxWidth: .infinity).background(.accent.gradient).radius() } } extension Image{ func iconStyle() -> some View { resizable().frame(width: 16, height: 16) } }