I have a UIView that contains a UIToolBar with two UIButtons and a Flexible space inbetween. For some weird reason on the iPhone 6 and 6Plus but not on any other model of iPhone the left and right UIButton in the UIToolBar appear to be displaying half on and half off of the screen.
Here is an example of the issue I am having for the iPhone 6 / 6Plus
And here is the way it looks on every other i device
Here is the code I am using to create the UIToolBar, Buttons and Label.
UILabel *toolBarLabel = [[UILabel alloc] initWithFrame:CGRectMake((ScreenWidth - 150.0) / 2, 3.0, 150.0, 40.0)];
toolBarLabel.font = [UIFont boldSystemFontOfSize:16.0];
toolBarLabel.textColor = [UIColor whiteColor];
toolBarLabel.textAlignment = NSTextAlignmentCenter;
toolBarLabel.backgroundColor = [UIColor clearColor];
toolBarLabel.text = @"Calculator";
prefToolBar = [[UIToolbar alloc] init];
[prefToolBar setTranslucent:NO];
prefToolBar.clipsToBounds = YES;
[[UIToolbar appearance] setBarTintColor:[UIColor colorWithRed:colorController.oRed/255.0 green:colorController.oGreen/255.0 blue:colorController.oBlue/255.0 alpha:1.0]];
[prefToolBar addSubview:toolBarLabel];
// add buttons
// create an array for the buttons
NSMutableArray* BarbuttonsArray = [[NSMutableArray alloc] initWithCapacity:5];
// create a Cancel button
UIBarButtonItem * cancelButton = [[UIBarButtonItem alloc] initWithTitle:@"Close"
style:UIBarButtonItemStylePlain
target:self
action:@selector(closeUIButton)];
cancelButton.style = UIBarButtonItemStylePlain;
cancelButton.tintColor = [UIColor whiteColor];
[BarbuttonsArray addObject:cancelButton];
UIBarButtonItem *flexible = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
[BarbuttonsArray addObject:flexible];
// create a submitButton
saveButton = [[UIBarButtonItem alloc]initWithTitle:@"Search"
style:UIBarButtonItemStylePlain
target:self
action:@selector(submitButton)];
saveButton.style = UIBarButtonItemStylePlain;
saveButton.tintColor = [UIColor whiteColor];
[BarbuttonsArray addObject:saveButton];
// put the BarbuttonsArray in the toolbar and release them
[prefToolBar setItems:BarbuttonsArray animated:NO];
UIView *frameToolbar = [[UIView alloc] initWithFrame:CGRectMake(0.0, 44.0, ScreenWidth, 0.5)];
frameToolbar.backgroundColor = [UIColor lightGrayColor];
[prefToolBar addSubview:frameToolbar];
UPDATE
Just adding the method I am using to return screen Width and Height, for further information on what I am doing.
@implementation calcScreenSize
+(CGFloat)screenWidth {
if(UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation)){
return [UIScreen mainScreen].bounds.size.width;
}else
return [UIScreen mainScreen].bounds.size.height;
}
+(CGFloat)screenHeight {
if(UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation)){
return [UIScreen mainScreen].bounds.size.height;
}else
return [UIScreen mainScreen].bounds.size.width;
}