I am having an issue with Tabbar Controller that images of tab bar item is blur in retina iOS devices . Here is my code for images in tab bar item is following:
float itemW;
CGRect screenBounds = [[UIScreen mainScreen] bounds];
CGFloat screenScale = [[UIScreen mainScreen] scale];
CGSize screenSize = CGSizeMake(screenBounds.size.width * screenScale, screenBounds.size.height * screenScale);
float itemH= self.tabBarController.tabBar.frame.size.height;
itemW= self.tabBarController.tabBar.frame.size.width;
//itemW=itemW+self.tabBarController.tabBar.frame.origin.x*2;
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){
itemW=itemW/5;
NSLog(@"WIDTH OF %f%f",itemW,itemH);
// itemH= 60 ;
}
else{
itemW=itemW/5-40;
//itemH= self.tabBarController.tabBar.frame.size.height;
}
CGSize newSize = CGSizeMake(itemW,itemH);
CGSize newSize1 = CGSizeMake(itemW,itemH);
NSArray *tabImg=[[NSArray alloc] initWithObjects:@"pc.png",@"fav.png",@"cont01.png",@"dial01.png",@"tool01.png",nil];
NSArray *unSelect=[[NSArray alloc] initWithObjects:@"pc01.png",@"fav01.png",@"cont.png",@"dial.png",@"tool.png",nil];
//tabbar item images
int k=[self.tabBarController.tabBar.items count];
for (int i=0; i<k; i++) {
UIImage *imageName=[UIImage imageNamed:[tabImg objectAtIndex:i]];
UIImage *imageName1=[UIImage imageNamed:[unSelect objectAtIndex:i]];
UIGraphicsBeginImageContext(newSize);
[imageName drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIGraphicsBeginImageContext(newSize1);
[imageName1 drawInRect:CGRectMake(0, 0, newSize1.width, newSize1.height)];
UIImage *newImage1 = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[[[self.tabBarController.viewControllers objectAtIndex:i] tabBarItem]setFinishedSelectedImage:newImage withFinishedUnselectedImage:newImage1];
}
And size of all images are 96X80 pixels. Now I am not getting what cause blurred images. Help me to resolve this problem.