我将在 SwiftUI 中的何处绘制 CGPath
Where would I draw CGPaths in SwiftUI
通常您会使用自定义视图和其中的 draw(rect:
) 方法来绘制路径,但因为我没有 UIView
s(并且不想使用 UIKit
集成) 我可以在哪里画画?
您将使用 GeometryReader
和 Path
return GeometryReader { geometry in
Path { path in
path.addPath(...)
}
}
Apple
关于该主题的 Swift Tutorial
通常您会使用自定义视图和其中的 draw(rect:
) 方法来绘制路径,但因为我没有 UIView
s(并且不想使用 UIKit
集成) 我可以在哪里画画?
您将使用 GeometryReader
和 Path
return GeometryReader { geometry in
Path { path in
path.addPath(...)
}
}
Apple
关于该主题的 Swift Tutorial