我正在对UITabBarItem映像使用XCode系统映像(SF符号)。我想删除我所做的UITabBarItem标题。但也会将UITabBarItem图像稍微向下移动。
在过去,当我不使用系统映像时,使用UIEdgeInsets就可以很好地工作。但是,这似乎对系统映像没有影响。
代码:
let imageConfiguration = UIImage.SymbolConfiguration(weight: .regular)
let imageInsets = UIEdgeInsets(top: 8, left: 0, bottom: -8, right: 0)
lazy var activityTabBarItem: UITabBarItem = {
let image = UIImage(systemName: "stopwatch")?.applyingSymbolConfiguration(imageConfiguration)
let tabBarItem = UITabBarItem(title: nil,
image: image,
selectedImage: image)
tabBarItem.imageInsets = imageInsets
return tabBarItem
}()有解决这个问题的办法吗?
发布于 2021-06-11 02:11:37
我花了一段时间,但您可以使用withBaselineOffset(fromBottom:(CGFloat) UIImage属性
示例:
UIImage(systemName: "someName")?.withBaselineOffset(fromBottom: 6.0)我花了几个小时,但我在我的SwiftUI自定义tabBarController上遇到了这个问题。抱歉,回复晚了。
发布于 2022-02-03 16:45:57
需要使用UIImage的- withAlignmentRectInsets(_ alignmentInsets: UIEdgeInsets)属性,才能成功设置SFSymbols的插入。下面是你的案例中的代码:
image.withAlignmentRectInsets(UIEdgeInsets(top: 0, left: 0, bottom: -6, right: 0)https://stackoverflow.com/questions/60843359
复制相似问题