Reputation: 3819
I'm trying to make a UIButton
the same width as its title by doing this:
CGSize stringSize = [[tagArray lastObject] sizeWithAttributes:@{NSFontAttributeName:@"System 14.0"}];
tagButton.frame = CGRectMake(x, y, stringSize.width, 30);
However it's crashing on the CGSize
line. Any pointers? The object in the array is just a regular NSString
.
Upvotes: 0
Views: 32
Reputation: 2005
Change the first line to:
CGSize stringSize = [[tagArray lastObject] sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14.0]}];
Upvotes: 1