2012-06-01 14 views

Respuesta

1

Realmente no creo que haya una manera "fácil" de hacerlo. Si observa la descripción de la API, incluso indica que no responde a la rutina setImage. He trabajado mucho subclasificando objetos de botones, etc. y creo que aquí es donde tendrías que ir para hacer lo que estás pidiendo.

0

Al igual que muchos de estos controles, lo hice subclasificando NSPopupButton (Célula) y luego haciendo todo mi propio dibujo en drawRect ... Sin embargo, hice trampa un poco y usé una imagen para hacer el triángulo real en lugar de intentar hazlo a través de primitivos.

- (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

hice esto y funcionó para mí.

(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. 
} 
Cuestiones relacionadas