在 UITabBarItem 中使用某些自定义字体时,我看到一些字符在底部被剪掉了。我也在 UIButton 上看到了这种情况,但找到了一个修复方法,即子类化 UIButton 并覆盖以下方法:
custom font on UIbutton title clipped on top of word
-(void)layoutSubviews
{
[super layoutSubviews];
CGRect frame = self.titleLabel.frame;
frame.size.height = self.bounds.size.height;
frame.origin.y = self.titleEdgeInsets.top;
self.titleLabel.frame = frame;
}
不幸的是,layoutSubviews 不可用于覆盖 UITabBarItem。有没有人遇到过这个问题并找到了解决办法?
最佳答案
您可以使用属性字典(setTitleTextAttributes:forState:
,继承自 UIBarItem)自定义标题(包括其颜色),您可以使用 setTitlePositionAdjustment(_ :forBarMetrics:)
属性。
关于ios - UITabBarItem 标题中的自定义字体被裁剪,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37110417/