//
//  GradientBar.m
//  mTLU
//
//  Created by Developer on 3/8/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "GradientBar.h"

@implementation GradientBar

#define MAIN_COLOR_COMPONENTS       { 0.153, 0.306, 0.553, 1.0, 0.122, 0.247, 0.482, 1.0 }
#define LIGHT_COLOR_COMPONENTS      { (224/255.0),(98/255.0),(103/255.0),1.0, (129/255.0),(40/255.0),(43/255.0), 1.0 }

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}


// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{ 
    // Drawing code
    // Render yourself instead.
    // You will need to adjust the MAIN_COLOR_COMPONENTS and LIGHT_COLOR_COMPONENTS to match your app
    
    // emulate the tint colored bar
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGFloat locations[2] = { 0.0, 1.0 };
    CGColorSpaceRef myColorspace = CGColorSpaceCreateDeviceRGB();
    
    CGFloat topComponents[8] = LIGHT_COLOR_COMPONENTS;
    CGGradientRef topGradient = CGGradientCreateWithColorComponents(myColorspace, topComponents, locations, 2);
    CGContextDrawLinearGradient(context, topGradient, CGPointMake(0, 0), CGPointMake(0,self.frame.size.height), 0);
    CGGradientRelease(topGradient);
    
 //   CGFloat botComponents[8] = MAIN_COLOR_COMPONENTS;
 //   CGGradientRef botGradient = CGGradientCreateWithColorComponents(myColorspace, botComponents, locations, 2);
  //  CGContextDrawLinearGradient(context, botGradient,
  //                              CGPointMake(0,self.frame.size.height/2), CGPointMake(0, self.frame.size.height), 0);
 //   CGGradientRelease(botGradient);
    
  //  CGColorSpaceRelease(myColorspace);
    
    
 //     top Line
      CGContextSetRGBStrokeColor(context, (238/255.0), (157/255.0), (169/255.0), 1.0);
      CGContextMoveToPoint(context, 0, 0);
      CGContextAddLineToPoint(context, self.frame.size.width, 0);
      CGContextStrokePath(context);
    
 //     bottom line
      CGContextSetRGBStrokeColor(context,(75/255.0), (15/255.0), (18/255.0), 1.0);
      CGContextMoveToPoint(context, 0, self.frame.size.height);
      CGContextAddLineToPoint(context, self.frame.size.width, self.frame.size.height);
      CGContextStrokePath(context);
      self.tintColor=[UIColor colorWithRed:(153/255.0) green:(65/255.0) blue:(69/255.0) alpha:1.0];
}


@end
