2012-06-23 4 views
2

나는 MFMailComposeViewController을 가지고 있으며 주제를 설정하면 제목으로도 설정됩니다. 질문은 제목과 색상의 글꼴을 어떻게 사용자 정의합니까?MFMailComposeViewController navigationBar 제목 글꼴 변경

MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; 
[picker setSubject:@"Feedback for MyApp"]; 

답변

8

모든보기 컨트롤러의 모든 탐색 바에 대한 app-delegate에서 내 앱의 글꼴을 일반적으로 변경했습니다. 당신이 당신의 네비게이션 바 제목 글꼴을 모두 변경 꺼리지 않는 경우에 다음과 같은 것을 넣어 applicationDidFinishLaunching:withOptions:

if ([[UINavigationBar class] respondsToSelector:@selector(appearance)]) 
     // set the navigation bar font to "courier-new bold 14" 
     [[UINavigationBar appearance] setTitleTextAttributes: 
     [NSDictionary dictionaryWithObjectsAndKeys:[UIColor lightGrayColor], UITextAttributeTextShadowColor, 
                [NSValue valueWithUIOffset:UIOffsetMake(1, 0)], UITextAttributeTextShadowOffset, 
                [UIFont fontWithName:@"CourierNewPS-BoldMT" size:14.0], UITextAttributeFont, 
                nil]]; 

업데이트 : 는 당신이이 일 경우에만 해당, 당신은 아마 appearanceWhenContainedIn를 사용하려는 경우 : Alexander Akers가 UIViewController가 UIAppearanceContainer를 상속 받았기 때문에 아래의 주석에서 제안한 인수를 사용합니다. 나는 appearanceWhenContainedIn : UINavigationBar에 포함 된 UIBarButtonItems와 같은 다른 경우에도 작동하므로이 상황에서도 비슷하게 작동해야합니다. 다음과 같이 MFMailComposeViewController 이후

+4

'[UINavigationBar appearanceWhenContainedIn : [MFMailComposeViewController class], nil]'? –

+0

해당 코드는 메일 작성보기 컨트롤러에 포함되어있을 때만 탐색 모음의 모양을 변경합니다. –

+0

@AlexsanderAkers, 제안을 반영하도록 답변을 업데이트했습니다. 나는 appearanceWhenContainedIn : UINavigationBar의 UIBarButtonItem에 대한 경험이 있습니다. 나는이 유형의 경우에는 사용하지 않았지만 실제로 작동해야합니다. –

-1

UINavigationController의 인스턴스, 당신은 topViewController의 titleView을 설정할 수 있습니다

UIViewController *controller = [mailController topViewController]; 

UIView *titleView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 170.0f, 44.0f)]; 
titleView.backgroundColor = [UIColor clearColor]; 

UILabel *label = [[UILabel alloc] initWithFrame:titleView.bounds]; 
label.textColor = [UIColor whiteColor]; 
label.backgroundColor = [UIColor clearColor]; 
label.text = @"Custom Font"; 
label.font = [UIFont italicSystemFontOfSize:27.0f]; 
label.textAlignment = UITextAlignmentCenter; 

[titleView addSubview:label]; 
[label release]; 

controller.navigationItem.titleView = titleView; 
[titleView release]; 
+0

이것이 작동하지 않으면, 복사 한 코드를 복사하고 내 mailController를 – xonegirlz

+0

@ xonegirlz로 바꿨습니다. 언급 한대로이 코드를 시도했습니다. 컨트롤 막대 특성을 변경하는이 스타일에 문제가있는 것을 기억합니다. 위의 대답에 설명 된대로 UIAppearance 항목에 의존하게 된 이유가 여기에 있습니다. 너도 그걸 시도 했니? 어떤 업데이트? –

3

내 생각 엔 그것 때문에 프로세스 간 제한으로 할 수 없다. 색상, 크기 및 글꼴 (기본 제공 시스템 글꼴 인 경우)을 변경할 수 있지만 내 앱에 포함 된 글꼴로 변경하려고하면 실패합니다.