Why doesn't this UIButton show its text label?

Posted by Dan Ray on Stack Overflow See other posts from Stack Overflow or by Dan Ray
Published on 2010-06-11T12:58:38Z Indexed on 2010/06/11 13:03 UTC
Read the original article Hit count: 294

Filed under:
|
|

Everything about this UIButton renders great except the text that's supposed to be on it. NSLog demonstrates that the text is in the right place. What gives?

UIButton *newTagButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[newTagButton addTarget:self action:@selector(showNewTagField) forControlEvents:UIControlEventTouchUpInside];
newTagButton.titleLabel.text = @"+ New Tag";
NSLog(@"Just set button label to %@", newTagButton.titleLabel.text);
newTagButton.titleLabel.font = [UIFont systemFontOfSize:17];
newTagButton.titleLabel.textColor = [UIColor redColor];
CGSize addtextsize = [newTagButton.titleLabel.text sizeWithFont:[UIFont systemFontOfSize:17]];
CGSize buttonsize = { (addtextsize.width + 20), (addtextsize.height * 1.2) };
newTagButton.frame = CGRectMake(x, y, buttonsize.width, buttonsize.height);
[self.mainView addSubview:newTagButton];

© Stack Overflow or respective owner

Related posts about iphone-sdk

Related posts about cocoa-touch