와 나는 그것이 UINavigationBar
에 포함 된 것 동안 UIBarButtonItem
을 사용자 정의하기 위해 노력하고있어.사용자 정의 UIBarButtonItem는 UIAppearance
나는 제목 텍스트 속성뿐만 아니라 배경 이미지를 사용자 정의하고 싶습니다.
는하지만, 경우에 탐색 모음이 UIPopoverController
에 포함되어, 나는 이러한 사용자 지정이 수행하고 싶지 않아요. 나는 팝 오버의 contentViewController으로 탐색 컨트롤러를 만들
:
//1.
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationController class], nil]
setBackgroundImage:[UIImage imageNamed:@"navigationBarBackgroundNormal"]
forState:UIControlStateNormal
forBarMetrics:UIBarMetricsDefault];
//2.
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationController class], nil]
setBackgroundImage:[UIImage imageNamed:@"navigationBarBackgroundHighlighted"]
forState:UIControlStateHighlighted
forBarMetrics:UIBarMetricsDefault];
//3.
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationController class], nil]
setTitleTextAttributes:@{UITextAttributeTextColor:[UIColor blueColor]}
forState:UIControlStateNormal];
//4.
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationController class], nil]
setTitleTextAttributes:@{UITextAttributeTextColor:[UIColor whiteColor]}
forState:UIControlStateHighlighted];
//5.
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationController class], [UIPopoverController class], nil]
setBackgroundImage:nil
forState:UIControlStateNormal
forBarMetrics:UIBarMetricsDefault];
//6.
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationController class], [UIPopoverController class], nil]
setBackgroundImage:nil
forState:UIControlStateHighlighted
forBarMetrics:UIBarMetricsDefault];
//7.
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationController class], [UIPopoverController class], nil]
setTitleTextAttributes:nil
forState:UIControlStateNormal];
//8.
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationController class], [UIPopoverController class], nil]
setTitleTextAttributes:nil
forState:UIControlStateHighlighted];
문제는 다음과 같습니다
이
내 코드입니다. 다른보기 컨트롤러가 푸시되면는 백 버튼이 자동으로 생성 및 적용 외관 라인에서 5,6,7,8-이다 - 좋다. 나는 새로운
UIBarButtonItem
을 만들고
rightBarButtonItem
으로 지정 그러나
, 라인 3,4,5,6 적용, 어떤 이유로 대신 (의미, 모양 프록시를 적용 제목은 라인 3,4 속성 탐색 표시 줄이 팝 오버 상태에 있더라도 배경 이미지는 모양 프록시가 올바르게 5,6)을 적용합니다.
탐색 모음이 팝 오버에 없으면 모든 것이 잘 작동합니다 라인 1,2,3,4가 적용됨). 네비게이션 컨트롤러가 팝 오버에있을 때 모양 프록시, 그것은 백 버튼해야하지만, UIBarButtonItem
을 위해 내가 만드는거야하지로 작동하는 이유
나는 알아낼 수 없습니다.