I am working on an iphone app. In the app, we have a toolbar at the main screen. In the toolbar, we have 3 buttons. The codes for the buttons are :
Code:
savedButton=[UIButton buttonWithType:UIButtonTypeCustom];
savedButton.bounds=CGRectMake(0,0,35.0,28.0);
[savedButton setBackgroundImage:[UIImage imageNamed:@"saved2.png"] forState:UIControlStateNormal];
[savedButton setBackgroundImage:[UIImage imageNamed:@"saved2.png"] forState:UIControlStateSelected];
[savedButton addTarget:self action:@selector(goSaved) forControlEvents:UIControlEventTouchDown];
[savedButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[savedButton setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
[savedButton setFont:[UIFont boldSystemFontOfSize:10]];
[savedButton setTitle:@"Saved" forState:UIControlStateNormal];
[savedButton setTitle:@"Saved" forState:UIControlStateSelected];
[savedButton setContentHorizontalAlignment:UIControlContentHorizontalAlignmentCenter];
[savedButton setImageEdgeInsets:UIEdgeInsetsMake(0.0, 0.0, 0.0, savedButton.titleLabel.bounds.size.width)];
[savedButton setTitleEdgeInsets:UIEdgeInsetsMake(35.0, savedButton.imageView.image.size.width, 0.0, 0.0)];
item2=[[UIBarButtonItem alloc] initWithCustomView:savedButton];
Its the same (similar) for the other two.
The problem here is, the other two are always fine. However, in this button, sometimes the text/title is hidden.
Can anyone kindly tell me what I am missing here ?
Thanks.