0

我对 iOS5 中的 UIButton 标题有疑问。它们被剪裁并显示在这张照片中。我不希望它们被剪辑,我想显示完整的标题。

在此处输入图像描述

在 iOS6 中,它们可以完美运行。

请告诉我如何解决这个问题?

4

5 回答 5

5

你只需要增加你的宽度UIButton来显示完整Title,我已经发布了示例片段以获得更好的想法,试试吧。你只需要增加按钮的宽度。

UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
[btn1 setFrame:CGRectMake(20, 200, 150, 25)];
[btn1 setTitle:@"This is Long Title" forState:UIControlStateNormal];
[self.view addSubview:btn1];
于 2013-05-20T15:10:17.740 回答
1

伙计们,我找到了解决方案。

很简单,你只需要在界面生成器中将按钮字体大小设置为比 UIapperance 字体代理更大或相同的字体大小。

于 2013-05-20T16:26:02.323 回答
0

For those of you here due to ellipsis and use of UIBarButtonItem know that there is a possibleTitles property on UIBarButtonItem with docs that read:

Use this property to provide a hint to the system on how to correctly size the bar button item to be wide enough to accommodate your widest title. Set the value of this property to an NSSet object containing all the titles you intend as possible titles for the bar button item. Use the actual text strings you intend to display.

This property applies to bar button items placed on navigation bars or toolbars.

于 2014-07-17T15:18:46.417 回答
0

我认为 AutoLayout 可能是罪魁祸首。检查您的约束是否没有强制标签缩小。

于 2013-05-20T15:57:34.610 回答
0

我假设您正在从代码中设置自定义字体,但您正在从 IB 中设置按钮的文本。所以我的简单解释是,正如@MichaelScaria 所说,您的自定义字体更大。文本正在裁剪,因为按钮内标签的大小已针对当前字体和大小进行了调整。由于您在设置文本后更改字体和大小,因此您需要重新设置按钮的标题或在该按钮上调用“sizeToFit”。

于 2013-05-20T16:29:09.530 回答