UISegmentedControl中的文本不完全居中吗? [英] Text in UISegmentedControl not exactly centered?

查看:67
本文介绍了UISegmentedControl中的文本不完全居中吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许只是我一个人,但在 UISegmentedControl 中,文本的底部填充似乎大于顶部填充。为什么会发生这种情况?

Maybe it's just me, but it seems like the bottom padding is greater than the top padding for the text in this UISegmentedControl. Why is this happening?

推荐答案

位置可能是正确的,但由于您的后代留有空间,因此在您眼中看起来是错误的后代,因为标题全为大写。幸运的是,您可以调整内容位置的 y 组件!有两种方法:

The position is probably correct, but it looks wrong to your eye because room is left for a descender, and there are no descenders because the titles are all caps. Luckily, you can adjust the y-component of the content position! There are two ways:


  • 在Interface Builder中,在每个段的属性检查器中,设置内容偏移量

  • In Interface Builder, in the attributes inspector for each segment, set the Content Offset

在代码中,调用 setContentPositionAdjustment:forSegmentType:barMetrics:

这篇关于UISegmentedControl中的文本不完全居中吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆