创建UIButton标题的宽度

时间:2015-06-06 13:59:17

标签: ios objective-c string uibutton

我试图通过这样做使UIButton与其标题的宽度相同:

CGSize stringSize = [[tagArray lastObject] sizeWithAttributes:@{NSFontAttributeName:@"System 14.0"}];
tagButton.frame = CGRectMake(x, y, stringSize.width, 30);

然而它在CGSize线上崩溃了。有什么指针吗?数组中的对象只是常规NSString

1 个答案:

答案 0 :(得分:1)

将第一行更改为:

-webkit-gradient(linear, top right, left bottom, from (rgba(255,0,0,1)), to(rgba(255,0,0,0)))