实战需求
macOS SwiftUI教程之从饼图中显示百分比
本文价值与收获
看完本文后,您将能够作出下面的界面

看完本文您将掌握的技能
- addArc
- move
- addLine
- .offset(x: 20, y: 20)
- .overlay( Text(“25%”)
基础知识
addArc
向路径添加圆弧,并指定半径和角度。
<code>mutating func addArc(center: CGPoint, radius: CGFloat, startAngle: Angle, endAngle: Angle, clockwise: Bool, transform: CGAffineTransform = .identity) </code>
实战代码
<code>import SwiftUI
struct ContentView: View {
var body: some View {
VStack{
ZStack {
Path { path in
path.move(to: CGPoint(x: 187, y: 187))
path.addArc</code>
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!