框架 SwiftUI 内的居中路径形状

问题描述

我对 SwiftUI 比较陌生,我一直在玩 PathUIBezierPath 无论如何我一直试图使用一些 UIBezierPath 数据来渲染一些汉字(中文/日文字符)我在网上找到的项目,但是,我似乎无法将 Path 置于框架内并想知道可能出了什么问题?

Image of Kanji bursting out of frame

有没有办法轻松地将框架内的路径居中?

产生附加图像输出代码是...

struct KanjiDrawView: View {
    let paths: [UIBezierPath]
    
    init(paths: [UIBezierPath]) {
        self.paths = paths
    }

    var body: some View {
        ZStack(alignment: .center) {
            ForEach(paths,id: \.self) { path in
                Path(path.cgPath)
                    .stroke(linewidth: 4)
            }
        }
        .frame(width: 200,height: 200)
        .background(Color.red)
    }
}

谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)