Change color of UINavigationBar title's inner shadow
UINavigationBar title has default inner shadow of black.
开发者_JAVA技巧Can I change this color ?
My approach is to subclass UINavigationItem and manipulate the setter for the title so it instead creates a titleView as an UILabel which can be configured at will.
-(void)awakeFromNib{
if(self.title){
[self setTitle:self.title];
}
}
-(id)initWithTitle:(NSString *)title{
self = [super init];
if(self){
[self setTitle:title];
}
return self;
}
-(void)setTitle:(NSString *)title{
[super setTitle:title];
UILabel* label = [[[UILabel alloc] init] autorelease];
label.text = title;
label.font = [UIFont fontWithName:@"Helvetica-Bold" size:18];
label.shadowColor = [UIColor lightGrayColor];
label.shadowOffset = CGSizeMake(0, -1);
label.textAlignment = UITextAlignmentCenter;
label.textColor = [UIColor blackColor];
label.backgroundColor = [UIColor clearColor];
[label sizeToFit];
self.titleView = label;
}
精彩评论