开发者

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;

}

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜