✨Custom Circle
在螢幕上畫點,可設定顏色、半徑、外框顏色、透明度等。

import SwiftUI
import Extensions // for 🌀View + .frame(_:_:)
// 📦 Point
public struct Point: View {
// properties
let color : Color
let radius : CGFloat
let strokeColor: Color
let opacity : Double
// init
public init(
_ radius : CGFloat = 10,
color : Color = .red,
strokeColor: Color = .black,
opacity : Double = 0.8
) {
self.radius = radius
self.color = color
self.strokeColor = strokeColor
self.opacity = opacity
}
// content
public var body: some View {
ZStack {
Circle()
.fill(color)
.frame(radius * 2, radius * 2)
.opacity(opacity)
.overlay(Circle().stroke(strokeColor)) // outline
.shadow(radius: 8)
}
}
}
Last updated
Was this helpful?