P5y*_*cH0 10 iphone uinavigationbar uilabel uinavigationitem ios
我们在导航栏中为titleView使用自定义字体.不知何故Apple总是把这个字体画得太高了.
当您在导航栏中使用自定义字体时,如何更正这种奇怪的偏移量?
Vad*_*off 23
我用过setTitleVerticalPositionAdjustment:forBarMetrics:
.
兼容性:从iOS 5开始提供.
Kju*_*uly 13
您可以将新视图设置为titleView
,然后为其添加新标签:
UIView * customTitleView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 200.0f, 40.0f)];
UILabel * customLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 20.0f, 200.0f, 20.0f)];
[customLabel setBackgroundColor:[UIColor clearColor]];
[customLabel setTextColor:[UIColor whiteColor]];
[customLabel setFont:[UIFont systemFontOfSize:12.0f]];
[customLabel setTextAlignment:UITextAlignmentCenter];
[customLabel setText:@"Your Text"];
[customTitleView addSubview:customLabel];
[customLabel release];
[self.navigationItem setTitleView:customTitleView];
[customTitleView release];
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5401 次 |
最近记录: |