Search code examples
cocoascrollviewernsscrollview

How to add a button or image to a vertical table header of scrollview?


I have seen a lot of programs had some buttons or images in the vertical or horizontal scrollview table header or bottom and click it to invloke some events, But I have searched interface builder library and not found some widget I can used , how these programs to implement it ? Thank you very much!


Solution

  • To add just above the vertical scroll bar, see -[NSTableView setCornerView:].

    To add to the left of the horizontal scroll bar, you'll need to subclass NSScrollView and (in addition to creating/configuring/adding the auxiliary view of your choice) override -tile. You'd call [super tile], then adjust the horizontal scroller to make room, then position the auxiliary view to taste.