提问人:Avinash Kumar 提问时间:8/22/2023 最后编辑:HangarRashAvinash Kumar 更新时间:8/23/2023 访问量:27
在iPad中,我的应用程序的UITabBaritems的标题文本显示截断,在iPhone中工作正常
In iPad the title text of UITabBaritems of my app is showing truncated, Working fine in iPhone
问:
标签栏项目文本在iPad上显示被截断,但在iPhone上工作正常。
这是我的代码:
class HomeTabBarController: UITabBarController {
override func viewDidLoad() {
super.viewDidLoad()
let tabBarAppearnace = UITabBarAppearance()
let tabFont = UIFont.boldSystemFont(ofSize: 18)
let selectedAttributes: [NSAttributedString.Key: Any]
= [NSAttributedString.Key.font: tabFont, NSAttributedString.Key.foregroundColor: UIColor.orange]
let normalAttributes: [NSAttributedString.Key: Any]
= [NSAttributedString.Key.font: tabFont, NSAttributedString.Key.foregroundColor: UIColor.black]
tabBarAppearnace.stackedLayoutAppearance.normal.titleTextAttributes = normalAttributes
tabBarAppearnace.stackedLayoutAppearance.selected.titleTextAttributes = selectedAttributes
//New
tabBarAppearnace.inlineLayoutAppearance.normal.titleTextAttributes = normalAttributes
tabBarAppearnace.inlineLayoutAppearance.selected.titleTextAttributes = selectedAttributes
tabBarAppearnace.compactInlineLayoutAppearance.normal.titleTextAttributes = normalAttributes
tabBarAppearnace.compactInlineLayoutAppearance.selected.titleTextAttributes = selectedAttributes
tabBar.standardAppearance = tabBarAppearnace
}
}
答:
-3赞
Chander Dhiman
8/22/2023
#1
let normalAttrs: [NSAttributedString.Key: Any] = [.foregroundColor: ThemeColor.gray, .paragraphStyle: NSParagraphStyle.default]
let selectedAttrs: [NSAttributedString.Key: Any] = [.foregroundColor: ThemeColor.red, .paragraphStyle: NSParagraphStyle.default]
评论
0赞
Mark Rotteveel
8/24/2023
尽管此代码可能会回答该问题,但我建议您也解释您的代码的作用以及它如何解决该问题。带有解释的答案通常更有帮助,质量更好,并且更有可能吸引赞成票。
评论