@H_502_2@
我正在尝试使用
Swift在iOS 11中使用新的大型标题系统.当标题太长时(参见图片示例),它会添加…而不是换行或缩小文本大小.如何添加换行符?
self.navigationController?.navigationBar.prefersLargeTitles = true self.navigationController?.navigationBar.largeTitleTextAttributes = [NSForegroundColorAttributeName: MyGlobalVariable.themeMainColor] self.navigationController?.navigationBar.largeTitleTextAttributes = [NSFontAttributeName: UIFont.systemFont(ofSize: 22)] navigationItem.title = "Search by Name"@H_502_2@
解决方法
试试这个:
for navItem in (self.navigationController?.navigationBar.subviews)! { for itemSubView in navItem.subviews { if let largeLabel = itemSubView as? UILabel { largeLabel.text = self.title largeLabel.numberOfLines = 0 largeLabel.lineBreakMode = .byWordWrapping } } }
它对我有用.
@H_502_2@ @H_502_2@@H_502_2@
@H_502_2@
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。