In the 2016 WWDC session "Crafting Modern Cocoa Apps", there is a description of how to set the offset of a window's content when using the "Full Size Content View" setting:
override func updateViewConstraints() {
if topConstraint == nil {
if let topAnchor = titleTextField.window?.contentLayoutGuide?.topAnchor {
topConstraint = titleTextField.topAnchor.constraint(equalTo: topAnchor, constant: 2)
topConstraint!.isActive = true
}
}
super.updateViewConstraints()
}
However, in Xcode 8.1 [editted], this does not compile, because NSWindow's contentLayoutGuide property is declared as
open var contentLayoutGuide: Any? { get }
Has anyone successfully used this property? If so, how? Did you have to cast the Any? type to something concrete, and if so, what?