Created
June 15, 2011 11:58
-
-
Save densa/1026937 to your computer and use it in GitHub Desktop.
Custom background for UIToolbar w/ UINavigationBar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface UIToolbar (CustomImage) | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "UIToolbar+CustomBackground.h" | |
#import <QuartzCore/QuartzCore.h> | |
@implementation UIToolbar (CustomImage) | |
- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx { | |
[super drawLayer:layer inContext:ctx]; | |
if (self.barStyle == UIBarStyleBlackOpaque) { | |
CALayer *imgLayer = [[CALayer alloc] init]; | |
[imgLayer setContents:(id)[[UIImage imageNamed: @"toolbar.png"] CGImage]]; | |
[imgLayer setBounds:CGRectMake(0.0f, 0.0f, self.frame.size.width, self.frame.size.height)]; | |
[imgLayer setPosition:CGPointMake(self.bounds.size.width/2,self.bounds.size.height/2)]; | |
[layer insertSublayer:imgLayer atIndex:0]; | |
[imgLayer release]; | |
} | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment