Skip to content

Instantly share code, notes, and snippets.

@hira22
Created August 17, 2021 12:58
Show Gist options
  • Save hira22/3874525cde4969d276e69ceda6a25254 to your computer and use it in GitHub Desktop.
Save hira22/3874525cde4969d276e69ceda6a25254 to your computer and use it in GitHub Desktop.
//
// LineDivider.swift
//
//
// Created by hira22 on 2021/08/13.
//
import SwiftUI
struct LineDivider: View {
struct Line: Shape {
func path(in rect: CGRect) -> Path {
var path = Path()
path.addLines([
CGPoint(x: .zero, y: rect.maxY / 2),
CGPoint(x: rect.maxX, y: rect.maxY / 2)
])
return path
}
}
let text: String
var body: some View {
HStack(spacing: 16.0) {
LineDivider()
.stroke(lineWidth: 2.0)
Text(text)
.layoutPriority(1)
LineDivider()
.stroke(lineWidth: 2.0)
}
.foregroundColor(Color(.systemGray))
}
}
struct LineDivider_Previews: PreviewProvider {
static var previews: some View {
LineDivider(text: "LineDivider")
.frame(height: 40)
.previewLayout(.sizeThatFits)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment