2011-08-19 6 views
0

나는 문제는 탐색 모음에 100 % 일치하지 않는 도구 모음의 배경 인 탐색 컨트롤러추가 도구 모음 - 컬러 불일치

UIToolbar* toolbar = [[UIToolbar alloc] 
         initWithFrame:CGRectMake(0, 0, 100, 44)]; 
toolbar.tintColor = [UIColor clearColor]; 
[toolbar setBarStyle: UIBarStyleBlackTranslucent]; 

... 

에 여러 개의 버튼을 추가하려면 다음 코드를 사용했다. 툴바 상단에 작은 선이 나타납니다. 색상은 거의 동일하지만주의 깊게 보면 당신은 내가 어떻게 배경 색상을 얻을 수있는 탐색 모음

self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:.0 green:.0 blue:.0 alpha:.4]; 

어떤 아이디어의 배경을 설정하는 대리자에서 다음을 수행 직사각형 ...

를 볼 수 있습니다 탐색 막대의 색상과 일치합니까?

screen capture of the problem

답변

0

이 일을하는 가장 좋은 방법은 도구 모음을 완전히 투명하게하는 것입니다. 이를 수행하는 한 가지 방법은 UIToolbar를 서브 클래 싱하고 drawRect :를 오버라이드하여 아무 것도하지 않는 것입니다.

@implementation UITransparentToolbar 

- (id)initWithCoder:(NSCoder *)decoder 
{ 
    if (self = [super initWithCoder:decoder]) 
    { 
     self.backgroundColor = [UIColor clearColor]; 
     self.opaque = NO; 
     self.translucent = YES; 

    } 
    return self; 
} 

- (void)drawRect:(CGRect)rect 
{ 
} 

- (void)dealloc 
{ 
    [super dealloc]; 
} 

@end 
0

이 응답에 따라에서 iOS 5 같은데 이상 트릭없이 지원 :

는 여기 UITransparentToolbar의 내 구현 (.이 도구 모음은 XIB를 통해 생성됩니다 가정합니다)입니다

https://stackoverflow.com/a/9109910/1179521

그리고 그것은 나를 위해 일했습니다!