How to add a multiline title bar in UINavigationController
- by Cocoa Matters
I have try to add a two line title bar in UINavigationController
I want to adjust font size automatically set according to string length.My String max size goes to 60. I have try to implemented through following code
UILabel *bigLabel = [[UILabel alloc] init];
bigLabel.text = @"1234567890 1234567890 1234567890 1234567890 1234567890 123456";
bigLabel.backgroundColor = [UIColor clearColor];
bigLabel.textColor = [UIColor whiteColor];
bigLabel.font = [UIFont boldSystemFontOfSize:20];
bigLabel.adjustsFontSizeToFitWidth = YES;
bigLabel.clipsToBounds = NO;
bigLabel.numberOfLines = 2;
bigLabel.textAlignment = ([self.title length] < 10 ? NSTextAlignmentCenter : NSTextAlignmentLeft);
[bigLabel sizeToFit];
self.navigationItem.titleView = bigLabel;
It didn't work for me can you help me please. I have to made this for iPhone and iPad screen