UIButton's titleLabel.text is not displayed on Cocoa Touch-Collection of common programming errors
After I create a new UIButton at runtime, and set its titleLabel’s text, the button’s text is still not displayed.
What am I doing wrong?
-(IBAction) cloneMe: (id) sender{
if (!currentY) {
currentY = [sender frame].origin.y;
}
UIButton *clone = [UIButton buttonWithType:UIButtonTypeRoundedRect];
CGRect cloneFrame = [sender frame];
cloneFrame.origin.y += currentY + cloneFrame.size.height + 30;
clone.frame = cloneFrame;
[clone titleLabel].text = @"I'm a clone";
[[sender superview] addSubview:clone];
currentY = cloneFrame.origin.y + cloneFrame.size.height;
}