GradientBackgroundView.m 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. //
  2. // GradientBackgroundView.m
  3. // iPodConverter
  4. //
  5. // Created by Pierre d'Herbemont on 1/12/08.
  6. // Copyright 2008 __MyCompanyName__. All rights reserved.
  7. //
  8. #import "GradientBackgroundView.h"
  9. /**********************************************************
  10. * Why not drawing something nice?
  11. */
  12. @implementation GradientBackgroundView
  13. - (void)awakeFromNib
  14. {
  15. /* Buggy nib files... Force us to be on the back of the view hierarchy */
  16. NSView * superView;
  17. [self retain];
  18. superView = [self superview];
  19. [self removeFromSuperview];
  20. [superView addSubview:self positioned: NSWindowBelow relativeTo:nil];
  21. }
  22. - (void)drawRect:(NSRect)rect
  23. {
  24. NSColor * topGradient = [NSColor colorWithCalibratedWhite:.12f alpha:1.0];
  25. NSColor * bottomGradient = [NSColor colorWithCalibratedWhite:0.55f alpha:0.9];
  26. NSGradient * gradient = [[NSGradient alloc] initWithColorsAndLocations:bottomGradient, 0.f, bottomGradient, 0.1f, topGradient, 1.f, nil];
  27. [gradient drawInRect:self.bounds angle:90.0];
  28. [super drawRect:rect];
  29. }
  30. @end