Note that there are some explanatory texts on larger screens.

plurals
  1. POButton above NSScrollView using autoLayout
    primarykey
    data
    text
    <p>I have a Cocoa project using Autolayout, and I want to put a button (actually an <code>NSPathControl</code>) over a <code>NSScrollView</code> so that it stays in the same place on the screen even when the scrollView is scrolled.</p> <p>Whenever I add the button to the scrollView's parent, it ends up behind the scrollView (even if I explicitly use <code>addSubview:positioned:relativeTo:</code>. How do I get it to float above the scrollView?</p> <p>My fallback is to put it inside of the scrollView, turn on <code>translatesAutoresizingMaskIntoConstraints</code> and update the frame as the scrollView is scrolled. I would strongly prefer to use autolayout if possible though...</p> <p>Edit: Here is the layout code for the button (the layout for content in the scrollView is quite complex):</p> <pre><code>NSButton *button = [[NSButton alloc]initWithFrame:NSZeroRect]; button.translatesAutoresizingMaskIntoConstraints = NO; button.wantsLayer = YES;//Added incase this affects ordering (it doesn't seem to make a difference) [self.superview addSubview:button positioned:NSWindowAbove relativeTo:self]; [self.superview addConstraint:[NSLayoutConstraint constraintWithItem:button attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:20]]; [self.superview addConstraint:[NSLayoutConstraint constraintWithItem:button attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop multiplier:1.0 constant:20]]; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload