I can't seem to modify the font size of a UILabel with the following code:

itemTitle.font = [UIFont systemFontOfSize:25];

As i increase the number 25 to something greater, it seems to only add a top margin to the label, which consequently pushes the text down so much, so that the text gets cut off at the bottom or completely overflows.

i have another UILabel elsewhere with systemFontOfSize 25, and it's much smaller than the itemTitle text. What's going on? Isn't 25 supposed to be an absolute value?

i am so confused on how to programmatically change font size of uilabels.

推荐答案

Check that your labels aren't set to automatically resize. In IB, it's called "Autoshrink" and is right beside the font setting. Programmatically, it's called adjustsFontSizeToFitWidth.

Objective-c相关问答推荐

iOS8:退出应用程序后不久出现蓝条正在使用您的位置

UIAlertController:supportedInterfaceOrientations 被递归调用

如何更改 UIButton 的突出显示 colored颜色 ?

将 NSArray 保存到 NSUserDefaults 并在 NSMutableArray 中获取它

Objective C:给定一个Class id,我可以判断这个类是否实现了某个协议吗?还是有一定的 Select 器?

如何为代码自动格式化设置 Xcode 插件

setFont 已弃用?

在objective-c / cocoa-touch中是否有一个方便的功能来找到最小的数字?

奇怪的错误 NSAssert

如何以编程方式移动 UIScrollView 以集中在键盘上方的控件中?

Cocoa 的依赖注入框架?

无法加载 xcode 项目,因为它已从另一个项目或工作区打开

如何对包含数字的 NSMutable 数组进行排序?

NSMutableArray 按顺序添加对象

深入了解保留周期

UITableViewCell 点击展开

UITableView,我如何知道 cellForRowAtIndexPath 期间的哪个部分?

如何根据按钮按下重新加载/刷新 UIPickerView(带有新数据数组)?

Facebook SDK 登录永远不会在 iOS 9 上回调我的应用程序

无法更改 UILabel 文本 colored颜色