Reputation: 569
I'm setting an image for a button and it does not show up. As far as I know setting it as backgroundImage will stretch it as the button's size hence I'd rather use setImage instead.
self.mainMapButton = [UIButton buttonWithType:UIButtonTypeCustom];
[self.mainMapButton setImage:[UIImage imageNamed:@"map_icon"] forState:UIControlStateNormal];
[self.tabView addSubview:self.mainMapButton];
self.mainMapButton.center = CGPointMake((self.tabView.frame.size.width/4)/2, self.tabView.frame.size.height/2);
What's wrong with my code?
Upvotes: 0
Views: 46
Reputation: 3315
Perhaps a silly suggestion, but don't you need to set the button frame?
self.mainMapButton.frame = CGRectMake(100.0, 180.0, 100.0, 40.0);
Upvotes: 2
Reputation: 569
Turns out if you don't set its frame it won't show up... I assumed it would because UIImageView doesn't need frame setting and somehow because I'm setting an image.. thought it'd work the same but no.
Upvotes: 0