Files
NetNewsWire/Shared/Extensions/NSView-Extensions.swift
Mario Guzman 1eb4002c78 Fix timeline, details views for proper toolbar scroll behavior
Both the details and timeline container views were not extending behind the toolbar and thus content would not show when scrolled behind it. Top anchors should anchor to the top of the super view rather than safe area guides and AppKit automatically adjusts the scroll insets for NSToolbar and optionally (if available) NSTitlebarAccessoryViewController. This allows for the divider to appear when content scrolls behind it and for content to "shine through" the translucency of the NSToolbar.
2022-10-01 12:03:51 -07:00

21 lines
1019 B
Swift

//
// NSView-Extensions.swift
// NetNewsWire
//
// Created by Brent Simmons on 2/13/19.
// Copyright © 2019 Ranchero Software. All rights reserved.
//
import AppKit
extension NSView {
func constraintsToMakeSubViewFullSize(_ subview: NSView) -> [NSLayoutConstraint] {
let leadingConstraint = NSLayoutConstraint(item: subview, attribute: .leading, relatedBy: .equal, toItem: self, attribute: .leading, multiplier: 1.0, constant: 0.0)
let trailingConstraint = NSLayoutConstraint(item: subview, attribute: .trailing, relatedBy: .equal, toItem: self, attribute: .trailing, multiplier: 1.0, constant: 0.0)
let topConstraint = NSLayoutConstraint(item: subview, attribute: .top, relatedBy: .equal, toItem: self, attribute: .top, multiplier: 1.0, constant: 0.0)
let bottomConstraint = NSLayoutConstraint(item: subview, attribute: .bottom, relatedBy: .equal, toItem: self, attribute: .bottom, multiplier: 1.0, constant: 0.0)
return [leadingConstraint, trailingConstraint, topConstraint, bottomConstraint]
}
}