iOS에서 uinavigationbar를 색칠하십시오
-
11-09-2019 - |
문제
나는 주황색 내비게이션 바를 색상화했다 :
navigationController.navigationBar.tintColor = [UIColor colorWithRed:0.88 green:0.52 blue:0.27 alpha:1];
모든 것이 잘 작동하고 모든 버튼은 막대만큼 주황색이지만 IC Cames가 사용자 정의 오른쪽 항목 메뉴에 있으면 파란색으로 표시됩니다. 이것은 스크린 샷입니다. http://img146.imageshack.us/img146/5605/schermata20091202a14565.png
그리고 이것은 오른쪽 버튼의 코드입니다.
UIView *container = [[UIView alloc] init];
UIToolbar *tools = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 80, 45)];
NSMutableArray *buttons = [[NSMutableArray alloc] initWithCapacity:2];
UIBarButtonItem *bi = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addGadget:)];
bi.style = UIBarButtonItemStyleBordered;
[buttons addObject:bi];
[bi release];
bi = [[UIBarButtonItem alloc]
initWithImage:[UIImage imageNamed:@"less.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(setEditing:)];
[buttons addObject:bi];
[bi release];
[tools setItems:buttons animated:NO];
[buttons release];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:tools];
[tools release];
모든 것을 오렌지로 만드는 방법?
해결책
당신은 설정해야합니다 tintColor
의 UIToolbar
대상과 동일합니다 UINavigationBar
.
a UIToolbar
a와 동일하지 않습니다 UINavigationBar
, 배경 구배/색상은 약간 다릅니다. Uitoolbar의 배경 검색을 설정해보십시오 +[UIColor clearColor]
또한 컨테이너가 필요하지 않을 수도 있습니다 UIView
, 부터 UIToolbar
서브 클래스입니다 UIView
, 당신은 그것을 그 자체로 만 CustomView로 사용할 수 있습니다.
제휴하지 않습니다 StackOverflow