更新时间:2022-11-02 12:27:01
显然 SF 符号默认以系统字体大小呈现.因此,如果您向省略号符号添加一半大小的基线偏移量,您几乎可以完全以这种方式将其垂直居中.
Apparently SF symbols are rendered with system font size by default. So if you add a baseline offset of half that size to the ellipsis symbol you could almost perfectly center it vertically that way.
这几乎是完美的,因为省略号有自己的高度,这个解决方案没有考虑到这个高度,即使它不多.
It's only almost perfect because ellipsis symbol has a height of its own which is not accounted for by this solution, even if it is not much.
self.tabBarItem.image = UIImage(systemName: "ellipsis")!.withBaselineOffset(fromBottom: UIFont.systemFontSize / 2)