[英]CALayer's property isGeometryFlipped doesn't work on macOS
我想將 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)
}
}
為什么我設置屬性isGeometryFlipped =真觀的層,幾何不從左下角切換到左上角?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.