pushdeer/ios/PushDeer-iOS/PushDeer/View/Common/Line.swift

38 lines
742 B
Swift
Raw Normal View History

2021-12-27 22:33:27 +08:00
//
// Line.swift
// PushDeer
//
// Created by HEXT on 2021/12/27.
//
import SwiftUI
/// 线
struct HLine: Shape {
func path(in rect: CGRect) -> Path {
Path { path in
path.move(to: CGPoint(x: rect.minX, y: rect.midY))
path.addLine(to: CGPoint(x: rect.maxX, y: rect.midY))
}
}
}
/// 线
struct VLine: Shape {
func path(in rect: CGRect) -> Path {
Path { path in
path.move(to: CGPoint(x: rect.midX, y: rect.minY))
path.addLine(to: CGPoint(x: rect.midX, y: rect.maxY))
}
}
}
struct Line_Previews: PreviewProvider {
static var previews: some View {
// 线
HLine().stroke(style: StrokeStyle(lineWidth: 1,dash: [5]))
// 线
VLine().stroke()
}
}