Skip to content

Instantly share code, notes, and snippets.

@EnesKaraosman
Last active April 16, 2020 12:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EnesKaraosman/190f308a9ef1f0a9d3b3aa0b2c0ce5d1 to your computer and use it in GitHub Desktop.
Save EnesKaraosman/190f308a9ef1f0a9d3b3aa0b2c0ce5d1 to your computer and use it in GitHub Desktop.
Balloon Shape
struct Balon: Shape {
func path(in rect: CGRect) -> Path {
// Orta - Alt nokta
let bottomCenter = CGPoint(x: rect.midX, y: rect.maxY)
// Orta - Üst nokta
let upCenter = CGPoint(x: rect.midX, y: rect.minY)
var path = Path()
path.move(to: bottomCenter) // Başlangıç noktası
// Sağ Yarım kısım )
path.addCurve(
to: upCenter,
control1: .init(x: rect.maxX, y: rect.midY), // Sağ - Orta
control2: .init(x: rect.maxX, y: rect.minY) // Sağ - Üst
)
// Sol Yarım kısım (
path.addCurve(
to: bottomCenter,
control1: .init(x: rect.minX, y: rect.minY), // Sol - Üst
control2: .init(x: rect.minX, y: rect.midY) // Sol - Orta
)
return path
}
}
// Kullanım
Balon().frame(width: 160, height: 160)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment