一个开源库,它为 SwiftUI 库提供扩展,以启用间距/字体网格和其他高级实用工具。
开发为可重用组件,用于 XII 在 iOS、macOS 和 watchOS 应用程序上的各种项目。
SwiftUIGrid 库以添加到你的项目中请参阅 LICENSE 文件。
extension View {
func padding(
top: CGFloat = 0.0,
trailing: CGFloat = 0.0,
bottom: CGFloat = 0.0,
leading: CGFloat = 0.0
) -> some View
}
将每个方向的内边距设置为提供的值。如果未提供特定方向的值,则假定为 0.0。
extension View {
func padding(
vertical: CGFloat = 0.0,
horizontal: CGFloat = 0.0
) -> some View
}
padding(top:trailing:bottom:leading) 的变体,用于设置垂直/水平内边距。
extension View {
func systemPadding() -> some View
}
将 View 的内边距重置为系统计算的默认值。
struct FontFace : Hashable {
let name: String?
let weight: Font.Weight
let design: Font.Design
init(
name: String? = nil,
weight: Font.Weight = .regular,
design: Font.Design = .default
)
func toFont(size: CGFloat) -> Font
func toFont<Size : RawRepresentable>(size: Size) -> Font
where Size.RawValue == CGFloat
}
定义一个可选命名的字体外观,具有特定粗细,允许将其转换为 Font 或 NSAttributedString。
应用程序可以将其自定义字体定义为此结构的扩展,例如
extension FontFace {
static let MyCustomFont = FontFace(name: "MyCustomFont", weight: .light)
static let MySystemFont = FontFace(weight: .light)
}
extension FontFace {
func toAttributes(size: CGFloat) -> [NSAttributedString.Key : UIFont]
func toAttributes<Size : RawRepresentable>(
size: Size
) -> [NSAttributedString.Key : UIFont] where Size.RawValue == CGFloat
}
extension FontFace {
func toAttributes(size: CGFloat) -> [NSAttributedString.Key : NSFont]
func toAttributes<Size : RawRepresentable>(
size: Size
) -> [NSAttributedString.Key : NSFont] where Size.RawValue == CGFloat
}
FontFace 大小 (Source)extension View {
func withAnimatedFont(
face: FontFace,
size: CGFloat
) -> some View
}
将给定的字体外观/大小样式应用于 View,但允许字体大小可动画化。
extension View {
func withAnimatedFont<Size : RawRepresentable>(
face: FontFace,
size: Size
) -> some View where Size.RawValue == CGFloat
}
将给定的字体外观/大小样式应用于 View,但允许字体大小(取自枚举原始值)可动画化。