내 탭 막대 항목의 글꼴 크기를 더 크게하려고합니다. 나는 AppDelegate에이 일을 시도했다 :tabBarItem 글꼴 속성 등록 정보를 설정하는 위치/방법/방법은 무엇입니까?
MenuTableViewController *mvc = [[MenuTableViewController alloc] init];
mvc.delegate = self;
mvc.restorationIdentifier = NSStringFromClass([mvc class]);
mvc.restorationClass = [self class];
UINavigationController *nav1 = [[UINavigationController alloc] initWithRootViewController:mvc];
SuperTabBarController *nav = [[SuperTabBarController alloc] init];
JudgeViewController *jvc = [[JudgeViewController alloc] init];
BuzzViewController *bvc = [[BuzzViewController alloc] init];
nav.viewControllers = @[jvc, bvc, nav1];
UIFont *tabBarFont = [UIFont systemFontOfSize:40];
NSDictionary *titleTextAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
tabBarFont, NSFontAttributeName, nil];
for(UIViewController *tab in nav.viewControllers) {
[tab.tabBarItem setTitleTextAttributes:titleTextAttributes forState:UIControlStateNormal];
NSLog(@"yo normal");
}
for(UIViewController *tab in nav.viewControllers) {
[tab.tabBarItem setTitleTextAttributes:titleTextAttributes forState:UIControlStateSelected];
NSLog(@"yo");
}
[UIView transitionWithView:self.window duration:0.5 options:UIViewAnimationOptionTransitionFlipFromLeft animations:^{self.window.rootViewController = nav;} completion:nil];
가 나는 또한 사전과 같이 정의했습니다 :.
NSDictionary *titleTextAttributes2 = @{NSFontAttributeName:
[UIFont fontWithName:@"Helvetica" size:20]};
그것은 사용자가 로그인 한 번 위임 프로토콜을 통해 호출되는 사용자 정의 함수에서의 내 NSLogs는 인쇄, 그러나 나는 또한 콘솔이 얻을 : 제목 글꼴 로그 outpu에도 불구하고이 명령을 전혀 변경하지 않는 것이 아닌 원하는대로
button text attributes only respected for UIControlStateNormal, UIControlStateSelected and UIControlStateDisabled. state = 1 is interpreted as UIControlStateSelected.
이 프로그램은 실행 ts.
그래서 나는 내 사용자 정의보기 컨트롤러에 대한이 내부 viewDidLoad에 넣어 :
UIFont *tabBarFont = [UIFont systemFontOfSize:40];
NSDictionary *titleTextAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
tabBarFont, NSFontAttributeName, nil];
[self.tabBarItem setTitleTextAttributes:titleTextAttributes forState:UIControlStateNormal];
[self.tabBarItem setTitleTextAttributes:titleTextAttributes forState:UIControlStateSelected];
을하지만이 또한 탭 표시 줄 제목의 글꼴 크기에 영향을 미치지 않았다.
어디에서 이러한 명령을 실행해야합니까?
감사합니다.
부록 마킹 대답은 내가 필요로 무엇을하지 않습니다,하지만 난 인스턴스 세터가 아닌 클래스 전체 세터를 사용하는 경우 나는 방법은 노력하고 있습니다 것으로 나타났습니다. 이들은 모두 같은 호출했다 (여전히 하나의 클래스 인스턴스의 속성을 설정하려고
NSDictionary *attribute = @{NSFontAttributeName:
[UIFont fontWithName:@"Helvetica" size:40]};
[[UITabBarItem appearance] setTitleTextAttributes:attribute forState:UIControlStateNormal];
하지만가 작동하지 않는 : 그래서 전 세계적으로 탭 표시 줄 항목 제목 텍스트를 변경하려면,이 마법처럼 작동합니다 기능 하나만 적용됨).
NSDictionary * attribute2 = @ {NSFontAttributeName : [UIFont fontWithName : @ "Helvetica"size : 10]}; [nav1.tabBarItem setTitleTextAttributes : attribute2 forState : UIControlStateNormal];
누구나 알고 계십니까? 클래스 인스턴스 호출이 아무 것도하지 않는 이유를 보지 않고 Apple Dev 문서를 여러 번 읽었습니다.
고맙습니다! 매우 감사. –