i want to split the view into three different parts.each part i want to set different color. i have tried using drawing methods in drawrect.i've succeded but the splitting should be done on button click. here is the code that i have used.
          -(void)drawRect:(CGRect)rect
            {
        int i=0;
        float width =rect.size.width/[elements count];
         CGRect paintRect;
         for (NSString *color in self.elements) 
        {
        paintRect = CGRectMake(rect.origin.x+(i*width), rect.origin.y, width, rect.size.height);
    i++;
    UIColor *colorr=[UIColor colorWithHexString:color];
    [colorr set]; 
    UIRectFill(paintRect);
       }
      }
enter code here
now i want to use this code on button click..... help...thanx in advanced