gpt4 book ai didi

ios - 如何从中间截断 View 标题

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:18:48 27 4
gpt4 key购买 nike

我想从中间截断 View 标题。

代码:-

self.title = [NSString stringWithFormat:NSLocalizedString(@"SearchResultWithCount", nil),  self.searchString,[self.sortedFileList count]];

输出:- SearchResultWithCount(61...

但想要标题类似于:- SearchRe...thCount(612)。

请帮帮我。

最佳答案

我遇到了同样的问题,试试下面的代码:

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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com