我想将NSView的几何图形更改为左上角。但结果不正确。(PS:结果在iOS平台上是正确的。)
我的代码就像这样&效果如下:
import Cocoa
class ViewController: NSViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.view.wantsLayer = true
self.view.layer?.isGeometryFlipped = true
let red = NSView(frame: NSRect(origin: .zero, size: CGSize(width: 400, height: 200)))
red.wantsLayer = true
red.layer?.backgroundColor = NSColor.red.cgColor
let yellow = NSView(frame: NSRect(origin: .zero, size: CGSize(width: 200, height: 100)))
yellow.wantsLayer = true
yellow.layer?.backgroundColor = NSColor.yellow.cgColor
red.addSubview(yellow)
view.addSubview(red)
}
}
为什么我设置View的图层的属性 isGeometryFlipped = true ,几何图形不会改变 从左下角到左上角?