It is a very common problem for iOS Developers that we want to use Colourful texts in the Default Navigation Bar but do not know how to do it. Today I am showing you how to use colourful text in the default Navigation Bar. We have to do it programmatically.
- (void)viewDidLoad
{
[super viewDidLoad];
self.title=@"You Tube Vedio";
UILabel *titleView = (UILabel *)self.navigationItem.titleView;
if (!titleView) {
titleView = [[UILabel alloc] initWithFrame:CGRectZero];
titleView.backgroundColor = [UIColor clearColor];
titleView.font = [UIFont boldSystemFontOfSize:20.0];
titleView.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5];
titleView.textColor = [UIColor redColor]; // Change to desired color
self.navigationItem.titleView = titleView;
[titleView release];
}
titleView.text = self.title;
[titleView sizeToFit];
self.navigationController.navigationBar.tintColor=[UIColor blackColor];
}
I hope it will be helpful to you .
Happy Coding
Mahboob
No comments:
Post a Comment