๐ผ๏ธGridLines
Last updated
Last updated
SwiftUI โฉ Drawing โฉ Shape โฉ Helper Shapes โฉ
โฌ๏ธ ้่ฆ๏ผ GridLinesShape
// 2022.02.10
import SwiftUI
/// vertical & horizontal grid lines in a rect.
/// ```
/// GridLines()
/// GridLines(rows: 5, cols: 5)
/// GridLines(color: .gray, border: .pink)
/// ```
struct GridLines: View {
var rows: Int = 10
var cols: Int = 10
var color: Color = .secondary.opacity(0.5) // grid line color
var border: Color = .primary.opacity(0.8) // border color
var body: some View {
GridLinesShape(rows: rows, cols: cols) // ๐ GridLinesShape
.stroke(color)
.border(border)
}
}
โฌ๏ธ ้่ฆ๏ผ .white()
struct GridLines_Previews: PreviewProvider {
static var previews: some View {
HStack {
GridLines()
.padding(8)
.background(.black)
GridLines(color: .white(0.3), border: .white(0.1))
.padding(8)
.background(.white(0.4)) // ๐ShapeStyle+ .white()
.border(.black)
GridLines(rows: 5, cols: 5, color: .orange, border: .pink)
.padding(8)
.background(.white(0))
}
.padding()
.frame(height: 200)
}
}
uses GridLinesShape.
used in Point's previews.
used in Vehicle.CarBodyShape's previews.