Cropped UIButton Title(裁剪的 UIButton 标题)
问题描述
我正在为 UIButton 的标题使用自定义字体.它可以工作,除非使用这种特殊字体,第一个字符的一部分被剪裁了.例如:
I am using a custom font for the title of a UIButton. It works, except with this particular font a portion of the first character is clipped. For example:
我尝试设置 contentEdgeInsets 和 titleEdgeInsets ,但似乎无法让它不被剪裁.我还尝试将 button.titleLabel.clipsToBounds 属性设置为 NO;
I tried setting the contentEdgeInsets and titleEdgeInsets and can't seem to get it not clipped. I also tried setting the button.titleLabel.clipsToBounds property to NO;
任何建议将不胜感激.
推荐答案
所以我最终将 UIButton 标题设置为 nil,并将我自己的 UILabel 作为子视图添加到 UIButton.我将 UILabel 框架设置为与按钮相同的大小,并将其设置为居中.
So I just ended up setting the UIButton title to nil and added my own UILabel as a subview to the UIButton. I set the UILabel frame to the same size as the button and set it to be centered.
我确信这不是最优雅的解决方案,但它可以完成工作.
Not the most elegant solution I am sure, but it gets the job done.
这篇关于裁剪的 UIButton 标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:裁剪的 UIButton 标题
基础教程推荐
- 如何将多个组件添加到 PickerView? 2022-01-01
- 在 appComponent dagger 2 中动态添加测试模块? 2022-01-01
- 在 Android 模拟器中激活网络位置提供程序? 2022-01-01
- 突出显示朗读文本(在 iPhone 的故事书类型应用程序中) 2022-01-01
- 我的 UIImageView 的任务 2022-01-01
- Android:STATE_SELECTED不工作 2022-01-01
- 新的@SystemApi 注解是什么意思,和@hide 有什么区别 2022-01-01
- 在 iOS8 中无法获得正确的键盘高度值 2022-01-01
- - (CGRect)convertRect:(CGRect)rect toView:(UIView *)view 如何工作 2022-01-01
- 可可/目标C(OSX不是iOS)从子对象访问父对象 2022-01-01
