2014-07-15 3 views
0

탭바 컨트롤러에 문제가있어 망막의 iOS 장치에서 이미지가 흐려지는 문제가 있습니다. 다음은 탭 표시 줄 항목의 이미지 코드입니다.TabBar 항목 망막 디스플레이의 이미지가 흐림

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]; 
} 

모든 이미지의 크기는 96X80 픽셀입니다. 이제 나는 이미지가 흐리게 보이는 것을 얻지 못하고있다. 이 문제를 해결할 수 있도록 도와주세요.

답변

0

이미지를 추가 할 때 이미지가 [email protected]라는 명명 규칙으로 추가되었는지 확인하십시오. 이렇게하면 지원되는 경우 고해상도 이미지를 사용하도록 os에 지시하여 퍼지 이미지를 정리합니다. @ 2x 버전을 추가하지 않으면 이미지의 일부 다운 샘플링을 발견했습니다. 당신은 여전히 ​​즉 myImage.ext이

자세한 내용

Using images in iPhone (normal and @2x)를 참조 코드에서 이미지 같은 방법으로 참조
관련 문제