This is what I have tried:
In storyboard I dragged a Custom View
I give it a Constraint of 0 in Top, Left and Bottom
Code Block @IBOutlet weak var nsView1: NSView! nsView1.wantsLayer = true nsView1.layer?.backgroundColor = NSColor.red.cgColor
How do you change screen size ? Do you mean window size ?How can I make it half of the screen even when the user changes the size of the screen?
Anyway, you have several ways:
create a second view, a few pixels wide ; make it transparent, no user interaction
put it below the first
create constraint to give it same height as the first one and distance of its top to the first bottom of 0
align it to the left of screen
create a constraint for the first view to the bottom of screen
create an IBOutlet for this constraints: bottomConstraint
in viewWillLayout, set bottomConstraint.constant to half height of screen