我已經設置UINavigationBar的titleview的下面給出:如何根據TitleView中文本的長度來設置UINavigationBar的高度?
UIView *labelView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 255, 40)];
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 200, 40)];
[label setTextColor:[UIColor whiteColor]];
label.lineBreakMode=UILineBreakModeWordWrap;
label.numberOfLines=0;
label.shadowColor = [UIColor colorWithRed:0.0f/255.0f green:0.0f/255.0f blue:0.0f/255.0f alpha:0.25f];
label.shadowOffset = CGSizeMake(0.0f, -1.0f);
label.textAlignment = UITextAlignmentCenter;
label.adjustsFontSizeToFitWidth=YES;
[label setBackgroundColor:[UIColor clearColor]];
switch (genreId) {
case 1:
[email protected]"Music";
self.navigationItem.titleView =label;
break;
case 3:
[email protected]"Family";
break;
case 6:
[email protected]"Literature";
break;
case 7:
[email protected]"Theatre";
break;
default:
label.frame=CGRectMake(0, 0, 255, 40);
label.text=ArtistName;
break;
}
[label setFont:[UIFont boldSystemFontOfSize:20.0]];
[labelView addSubview:label];
[self.navigationItem setTitleView:labelView];
[label release];
現在我想更新UINavigationBar的高度,因爲在標題視圖自動換行不會顯示,直到我們增加高度UINavigationBar。我該怎麼做?
導航欄的高度不能被默認增加。爲此進行子類化。 http://stackoverflow.com/questions/892905/change-iphone-navigation-bars-height – tipycalFlow 2012-04-16 10:21:26
更好地製作圖像,並將該圖像添加到UINavigationBar。 – Krunal 2012-04-16 10:27:25
默認導航欄高度44像素h – Deepesh 2012-04-16 10:33:47