ios - SwiftUI 中的 CGPath
问题描述
在使用SwiftUI
时,我对这行代码感到困惑:
xPath = Path(myPath.cgPath)
这里有一个更广泛的背景:
struct MyShape: Shape {
@Binding var xPath:Path
........
var myPath = Path()
myPath.move(to: somePoint1)
myPath.addLine(to: somePoint2)
myPath.addLine(to: somePoint3)
myPath.addLine(to: somePoint1)
xPath = Path(myPath.cgPath)
在执行该行之后,这是我在调试器控制台中得到的:
(lldb) p myPath
(Path) $R14 = {
storage = path (path = 0x0000000280e081c0)
}
(lldb) p myPath.cgPath
(NSObject) $R16 = 0x000000028298cfc0 {
baseNSObject@0 = {
isa = __NSCFType
}
}
(lldb) p myPath.description
(String) $R18 = "39.3916 34.8342 m 51.5 0 l 63.6084 34.8342 l 39.3916 34.8342 l"
(lldb) p xPath
(Path) $R20 = {
storage = empty
}
这看起来好吗?由于 myPath 包含某些内容,我觉得奇怪的是 xPath 看起来最后是空的。
我错过了什么吗?
解决方案
推荐阅读
- brainfuck - 如何打印“1989 年 6 月 4 日发生了什么?” 在BrainFuck?
- powerbi - Power BI 临时文件?
- javascript - 使用 Object.setPrototype() 修补同一文档中的混合 HTML 和 XML 元素
- android - Flutter:com.it_nomads.fluttersecurestorage 包不存在
- linux-kernel - lockdep 在 preempt-rt linux 内核中有用吗?
- node.js - PassportJS 没有在本地重定向
- javascript - 按下按钮 5 次结束过程并输出结果
- image - 返回“FileNotFoundError”,而文件已经存在
- python - Python3在异常期间阻止子进程执行
- android - Code Igniter Rest Api facebook 注册未将数据放入数据库。工作正常