How to increase the height of NSTableHeaderView?

后端 未结 3 859
天涯浪人
天涯浪人 2021-02-04 22:19

I need to implement a headerview with specific size and gradient. I have to insert images in certain cells of the headerview.Tried to create the cells

相关标签:
3条回答
  • 2021-02-04 22:20

    You don't need to subclass NSTableHeaderView.

    I was able to change the height of the header view using the following snippet in the controller class:

    -(void)awakeFromNib {
        NSRect frame = tableView.headerView.frame;
        frame.size.height = 26;
        tableView.headerView.frame = frame;
    }
    

    It should be noted that the scroll view takes care of the layout. It automatically changes the frame of the headerView as necessary, but leaves the height intact. Resizing the clip view etc as suggested in the other answer is not necessary.

    0 讨论(0)
  • 2021-02-04 22:35

    You can also create a NSTableHeaderView object, initialize it with a frame(rect with height and width) and set that NSTableHeaderView object to your table view.

     NSTableHeaderView *tableHeaderView = [[NSTableHeaderView alloc] initWithFrame:NSMakeRect(0, 0, 120, 60)];
        [myTableView setHeaderView:tableHeaderView];
    [tableHeaderView release];
    
    0 讨论(0)
  • 2021-02-04 22:46

    Following link helped me in solving the issue.

    http://lists.apple.com/archives/cocoa-dev/2003/Feb/msg00676.html

    You need to set the Frame for NSClipView, NSTableHeaderView and the CornerView This is how I implemented the same in Code.

    for(NSView * subview in [topScrollView subviews])
    {           
       for(NSView * subSubView in [subview subviews])
       {
          if([[subSubView  className] isEqualToString:@"NSTableHeaderView"] &&  [[subview className] isEqualToString:@"NSClipView"]) 
          {
             [subSubView setFrameSize:NSMakeSize(subSubView.frame.size.width, subSubView.frame.size.height+5)];//HeaderView Frame
             [subview setFrameSize:NSMakeSize(subview.frame.size.width, subview.frame.size.height+5)];//ClipView Frame
          }
    
        }
        if ([[subview className] isEqualToString:@"_NSCornerView"])
        {
           [subview setFrameSize:NSMakeSize(subview.frame.size.width, subview.frame.size.height+5)]; //CornerView Frame
        }
    }
    
    0 讨论(0)
提交回复
热议问题