Arrow color NSPopUpButton

Is there a way to adjust the color of the NSPopUpButton arrow? I looked around, but had not yet found an answer.

+5
source share
3 answers

I really don't think there is a “simple” way to do this. If you look at the API description, it even states that it does not respond to the setImage procedure. I have done quite a bit of work on button objects for subclassing, etc .... and I think that you will need to go here to do what you ask.

+1
source

, NSPopupButton (Cell), drawRect... , , , .

- (void)drawRect:(NSRect)dirtyRect 
{
  //...Insert button draw code here...
  //Admittedly the above statement includes more work than we probably want to do.
  //Assumes triangleIcon is a cached NSImage...I also make assumptions about location

  CGFloat iconSize = 6.0;
  CGFloat iconYLoc = (dirtyRect.size.height - iconSize) / 2.0;
  CGFloat iconXLoc = (dirtyRect.size.width - (iconSize + 8));

  CGRect triRect = {iconXLoc, iconYLoc, iconSize, iconSize};
  [triangleIcon drawInRect:triRect];
}
0

I did it and it worked for me.

(void)drawImageWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
    NSPopUpButton *temp = (NSPopUpButton*)controlView;

    NSString *strtile = temp.title;

    AppDelegate *appdel = (AppDelegate*)[NSApplication sharedApplication].delegate;
    NSFont *font = [NSFont systemFontOfSize:13.5];
   NSSize size = NSMakeSize(40, 10);// string size

    CGRect rect = controlView.frame;
    rect = CGRectMake((size.width + temp.frame.size.width)/2, rect.origin.y, 8, 17);

    [self drawImage:[NSImage imageNamed:@"icon_downArrow_white.png"] withFrame:rect inView:self.
}
0
source

All Articles