Slide 15
Slide 15 text
© ZOZO, Inc.
struct ArcView: Shape {
var startAngle: Double
var endAngle: Double
var animatableData: Double {
get { endAngle }
set { endAngle = newValue }
}
func path(in rect: CGRect) -> Path {
let rotationAdjustment = Angle(degrees: 90)
let adjustedStartAngle = Angle(degrees: startAngle) - rotationAdjustment
let adjustedEndAngle = Angle(degrees: endAngle) - rotationAdjustment
return Path { p in
p.addArc (
center: CGPoint(x: rect.midX, y: rect.midY),
radius: rect.width / 2,
startAngle: adjustedStartAngle, endAngle: adjustedEndAngle,
clockwise: false
)
p.addLine(to: CGPoint(x: rect.midX, y: rect.midY))
p.closeSubpath()
}
}
}
ArcViewͷ࣮
ԁހͷඳը
addArc
+
addLine & close
return Path { p in
p.addArc (
center: CGPoint(x: rect.midX, y: rect.midY),
radius: rect.width / 2,
startAngle: adjustedStartAngle,
endAngle: adjustedEndAngle,
clockwise: false
)
p.addLine(to: CGPoint(x: rect.midX, y: rect.midY))
p.closeSubpath()
} 15