Back button title missing with long screen title in iOS 7

不羁的心 提交于 2019-12-11 23:34:21

问题


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.


回答1:


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).




回答2:


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;



来源:https://stackoverflow.com/questions/22029173/back-button-title-missing-with-long-screen-title-in-ios-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!