I am stumped trying to add a localized label to a custom button.
I have tried this:
[button1 setImage:[UIImage imageNamed:buttonFile] forState: UIControlStateNormal];
NSString *buttonTitle = NSLocalizedString(@"RECORD", @"");
[button1 setTitle:buttonTitle forState:UIControlStateNormal];
this:
for (id label in [button1 subviews])
if ([label isKindOfClass:[UILabel class]])
{
[label setTextAlignment:UITextAlignmentCenter];
[label setFont:[UIFont fontWithName:fontName size:14]];
[label setText: NSLocalizedString(@"RECORD", @"")];// forState:UIControlStateNormal];
}
and this:
button1.titleLabel.text = NSLocalizedString(@"RECORD", @"");
I can see the button, but not the label. If I remove the button image, I can see the label. I’d really like to have both, and I’d prefer not to have buttons for each language, although that is possible..
Are there better ways?
Thanks!!
Use setBackgroundImage:ForState: instead of setImage: