我想从中间截断 View 标题。
代码:-
self.title = [NSString stringWithFormat:NSLocalizedString(@"SearchResultWithCount", nil), self.searchString,[self.sortedFileList count]];
输出:- SearchResultWithCount(61...
但希望标题类似于:- SearchRe...thCount(612)。
请帮帮我。
Best Answer-推荐答案 strong>
我遇到了同样的问题,试试下面的代码:
CGSize size=[[UIScreen mainScreen] bounds ].size;
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(size.width/2-120, 5, 200, 44)];
titleLabel.text = your_title_text;
titleLabel.lineBreakMode = NSLineBreakByTruncatingMiddle;
[self.navigationItem setTitleView:titleLabel];
[self.navigationController.navigationBar.topItem setTitleView:titleLabel];
关于ios - 如何从中间截断 View 标题,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/27635831/
|