navigationitem titleview定位问题中的标签

时间:2014-09-16 05:58:54

标签: ios label uinavigationitem titleview

我正在尝试在导航项目标题视图中放置标签。如果是长标题,则在推/弹到其他屏幕时,标签从其原始位置移动并发生转换 设置标签的代码:

- (void)setNavBarTitle:(NSString *)title {

        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0.0, 0.0, 320.0, 60.0)];
        label.font=[UIFont boldSystemFontOfSize:20.0];
        [label setBackgroundColor:[UIColor clearColor]];
        [label setNumberOfLines:0];
        [label setTextColor:[UIColor whiteColor]];
        [label setTextAlignment:NSTextAlignmentCenter];
        [label setText:title];
        [label sizeToFit];

        self.navigationItem.titleView = label;
        self.parentViewController.navigationItem.titleView = label;
    }

0 个答案:

没有答案