Change background to Textured NSWindow?

Discussion in 'Mac Programming' started by Danneman101, Jan 19, 2011.

  1. Danneman101 macrumors 6502

    Joined:
    Aug 14, 2008
    #1
    I've decided to go with the textured NSWindow simply because it looks so good for my intended app.

    However, the default metalic-looking texture seems to be non-editable, and all edits you can do to the window seems to be to change its backgroundcolor.

    This would be ok if the backgroundcolor did have the same shadow-effects as the default texture, but it doesnt and looks plain and boring.

    I've been thinking about workarounds, like making a whole new custom view, but before getting to that, is there anything I'm missing as to how to customize the background of a textured window? Is there a simpler way to get that same look but with another color, or is there a way to actually set the background texture?
     
  2. Blakeasd macrumors 6502a

    Joined:
    Dec 29, 2009
    #2
    Try this:
    Code:
    - (void)awakeFromNib
    {
    myImage = [[NSImage alloc] init]
    
    [self setNeedsDisplay:YES];
    }
    
    - (void)drawRect:(NSRect)rect
    {
    NSSize isize = [myImage size];
    [myImage drawInRect:[self bounds] fromRect:NSMakeRect(0.0, 0.0,
    isize.width, isize.height) operation: NSCompositeCopy fraction:1.0];
    }
    
     
  3. Danneman101 thread starter macrumors 6502

    Joined:
    Aug 14, 2008
    #3
    I keep getting this type of error:

    Code:
    incompatible type for argument 1 of 'drawInRect:fromRect:operation:fraction:
    
    ..for the line..

    Code:
    [img drawInRect:[self bounds] fromRect:NSMakeRect(0.0, 0.0, isize.width, isize.height) operation: NSCompositeCopy fraction:1.0];
    
     
  4. (marc) macrumors 6502a

    (marc)

    Joined:
    Sep 15, 2010
    Location:
    the woods
    #4
    Actually, setting the backgroundColor should do what you want. Are you sure you used it correctly?
     
  5. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #5
    What type is self?

    That is, what is the type of the class this code is in? Is it a view with a bounds method?
     

Share This Page