调整UIButton字体大小为width

问题描述

| 我有以下代码:
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0.0,0.0,25,25);

[[button layer] setCornerRadius:5.0f];
[[button layer] setMasksToBounds:YES];
[[button layer] setBackgroundColor:[[UIColor redColor] CGColor]];
[button.titleLabel setFrame:CGRectMake(0,25)];

[button setTitle:[NSString stringWithFormat:@\"%@\",[[topics objectAtIndex:indexPath.row] unread]] forState:UIControlStateNormal];
问题是,当文本中的字符串不长时,它可以正常显示(1-2位)。但是,当它很长时(3 ++位),我只能看到一个红色按钮,里面没有文本。我该如何调整? 我不认为:
[button.titleLabel setAdjustsFontSizeToFitWidth:YES];
做这份工作,对不对?     

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)