I would like to make my UIToolbar solid gray. This has to work for iOS 4.3+
I have subclassed my UIToolbar and added this
- (void)drawRect:(CGRect)rect {
UIGraphicsBeginImageContext(rect.size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSaveGState(ctx);
[[UIColor colorWithRed:64.0f/255.0f
green:64.0f/255.0f
blue:64.0f/255.0f
alpha:1.0f] set];
CGRect myRect = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
CGContextFillRect(ctx, myRect);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
CGContextRestoreGState(ctx);
UIGraphicsEndImageContext();
[image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
No way. The toolbar is always black.
any clues?
thanks.
You could just try using a solid gray background image. You can make a 1×1 pixel gray png image with the color you want. Then use the following code to set it as the background image and it will work on all iOS versions including 4.3 and below.