I have a simple problem with my buttons. Title is not visible. My code is :
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:[UIImage imageNamed:[NSString stringWithFormat:@"ikonki%d.png",i]] forState:UIControlStateNormal];
[button setTitle:@"Normal" forState:UIControlStateNormal];
[button setTitleColor: [UIColor whiteColor] forState: UIControlStateNormal];
[button setEnabled:YES];
[button addTarget:self
action:@selector(buttonHandler:)
forControlEvents:UIControlEventTouchUpInside];
button.tag = i;
button.frame = CGRectMake(10. + 77. * i, 125., 68 , 68);
[self.view addSubview:button];
yep, it is normal behaviour when you are using the
image
property.use the
backgroundImage
property instead of theimage
one, like this:UPDATE #1:
to reposition the title of the button under the button, use this way:
UPDATE #2:
to change the font of the title, try this one:
This can also happen if you forget to use the
@synthesize
on the button or variables related to it.