ios - UIbutton 标题上的自定义字体剪裁在单词顶部

标签 ios objective-c uibutton

我已经上传了自定义字体并使用以下代码将此字体应用到 UIbutton 的标题上

videoButton.titleLabel.font = [UIFont fontWithName:@"LaurenScript" size:20];

问题是标题被剪裁在第一个字母的顶部(见下图)。我在 UIlabel 上尝试了相同的字体,它工作正常,所以这不是字体的问题。我还尝试使用

更改 rectFrame
[videoButton.titleLabel setFrame:CGRectMake(0, 0, 300, 600)];

但这并没有做任何事情。 有人知道我该如何解决这个问题吗? 干杯

enter image description here

最佳答案

我有一个类似的问题,分音符在标题标签的顶部被切断。 我制作了一个 UIButton 子类并使用此代码来解决问题:

-(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;
}

关于ios - UIbutton 标题上的自定义字体剪裁在单词顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13225761/

相关文章:

ios - 平衡多行 UILabel

ios - 将参数从一个 View Controller 传递到另一个 View Controller 时崩溃

objective-c - 动画 CAShapeLayer 大小变化

ios - 如何通过 -addSublayer : respond to touch events? 添加 UI 元素

ios - 在 AutoLayout 中的 2 个项目之间水平居中

ios - ARC下的NSString可能导致-[__ NSArrayM长度]:无法识别的选择器发送到实例?

iphone - 日期对象显示的日期为负 5 :30hr when compare to current time.

ios - UITextView 没有在 UICollectionViewCell 中启动

ios - 如果这是在 Objective C 中使用自定义字符串属性的正确方法,为什么我不能提取正确的数值?

ios - 如何在TableView外侧实现iPad中的复选标记按钮