NSScrollView padding

I have an NSScrollView with an NSTableView inside.

enter image description here

As you can see, there is a 100px NSp that overlays the view on the table. (This is intentional, the overlay is a bit transparent, and you can see the table scroll shadow visible at the bottom).

The problem, of course, is that I need to add 100px of white space to the bottom of the scroll to compensate for the overlap. Otherwise, you will not be able to see the bottom of the table, it is covered by an overlay.

I tried changing the view of the clip, but it seems I was only able to change its frame (loss of transparent overlay effect).

I may not be doing it right, please help!

+3


source to share


2 answers


So what I understood was I needed to consistently enlarge the frame documentView

.

The best way I have found this is to subclass the Document View, which in this case is an NSTableView.

In a subclass of NSTableView, I have overridden setFrameSize:(NSSize)newSize



- (void)setFrameSize:(NSSize)newSize {
    newSize.height += 100;
    [super setFrameSize:newSize];
}

      

Which added 100px of padding to the bottom of the table view and hence scrolling.

+5


source


Here's the same thing in Swift 4 :



class TableViewPadded: NSTableView{
  //Add padding at bottom
  override func setFrameSize(_ newSize: NSSize) {
    let padded = NSSize(width: newSize.width, height: newSize.height+30)
    super.setFrameSize(padded)
  }
}

      

0


source







All Articles