sarunw
sarunw

Reputation: 8176

Change color of UINavigationBar title's inner shadow

UINavigationBar title has default inner shadow of black.

Can I change this color ?

Upvotes: 1

Views: 1346

Answers (1)

Jakob
Jakob

Reputation: 1146

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;

}

Upvotes: 2

Related Questions