How to change font size of title in iphone?
this is the code ,this will show the default size, i want to change the font size of the title becoz this titl开发者_高级运维e is too big n not showing the whole only "Cook Great Indian..." is showing...pl let me help out
- (void)viewDidLoad {
self.title = @"Cook Great Indian Recipes";
}
Try setting custom label for title label:
self.title = @"Cook Great Indian Recipes";
CGRect frame = CGRectMake(0, 0, [self.title sizeWithFont:[UIFont boldSystemFontOfSize:20.0]].width, 44);
UILabel *label = [[UILabel alloc] initWithFrame:frame];
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont boldSystemFontOfSize:17.0];
label.textAlignment = UITextAlignmentCenter;
self.navigationItem.titleView = label;
label.text = self.title;
[label release];
You can not change the font of title
. Instead create a UILabel
with your own customization and assign it as navigationItem's titleView
.
UILabel *titleLbl = [[UILabel alloc] init];
label.frame = CGRectMake(...
label.font = [UIFont ...
// And the other things
self.navigationItem.titleView = titleLbl;
[titleLbl release];
精彩评论