Back button title missing with long screen title i

2019-08-26 09:12发布

I am seeing that "Back" button title is missing when my screen title is big. I needed to show the entire title. Is there any workaround to this?

Please see attached the screenshot of navigation bar I see with long title.

enter image description here

2条回答
萌系小妹纸
2楼-- · 2019-08-26 09:41

Make your screen title smaller. You can take control of it by using a titleView that's a UILabel. The advantage is that you can set its size, and that it can truncate its text and/or make the text occupy two lines if the text is too big (rather than just growing, as the title does).

查看更多
劫难
3楼-- · 2019-08-26 09:47
UIView *iv = [[UIView alloc] initWithFrame:CGRectMake(0,0,170,35)];
[iv setBackgroundColor:[UIColor whiteColor]];

_titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 170, 35)];
_titleLabel.textAlignment = UITextAlignmentCenter;
[_titleLabel setFont:[UIFont boldSystemFontOfSize:16.0]];
[_titleLabel setBackgroundColor:[UIColor clearColor]];
[_titleLabel setTextColor:[UIColor blackColor]];
[_titleLabel setText:@""];
_titleLabel.clipsToBounds = false;
iv.clipsToBounds = false;
[iv addSubview:_titleLabel];
[self.navigationItem setTitleView:iv];

also you need @property (strong, nonatomic) UILabel* titleLabel;

查看更多
登录 后发表回答