标签:io ar color os sp for strong on bs
#import "UINavigationBar+CustomImage.h"
@implementation UINavigationBar (CustomImage)
-(UIImage *)drawImage:(NSString *)imageName
{
UIImage *image = [UIImageimageNamed:imageName];
CGSize ssySize = CGSizeMake(320, (IOS_VERSION_7)?64:44);
UIGraphicsBeginImageContext(ssySize);
[image drawInRect:CGRectMake(0, 0, ssySize.width, ssySize.height)];
UIImage *reImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return reImage;
}
- (UIImage *)barBackground
{
return [UIImageimageNamed:@"live_bg_yellow.png"];
}
- (void)didMoveToSuperview
{
//iOS5 only
if ([selfrespondsToSelector:@selector(setBackgroundImage:forBarMetrics:)])
{
[selfsetBackgroundImage:[selfdrawImage:@"live_bg_yellow.png"] forBarMetrics:UIBarMetricsDefault];
// 自定义导航栏字体颜色大小
[selfsetTitleTextAttributes:@{
NSForegroundColorAttributeName: [UIColorredColor],
NSFontAttributeName: [UIFontboldSystemFontOfSize:14],
}];
// [[UINavigationBar appearance] setTitleTextAttributes:@{
// NSForegroundColorAttributeName: [UIColor redColor],
// NSFontAttributeName: [UIFont boldSystemFontOfSize:14],
// }];
}
}
//this doesn‘t work on iOS5 but is needed for iOS4 and earlier
- (void)drawRect:(CGRect)rect
{
//draw image
[[selfbarBackground] drawInRect:rect];
}
@end
标签:io ar color os sp for strong on bs
原文地址:http://www.cnblogs.com/liman1990/p/4122687.html