2015-10-16 15 views
0

我必須用2種不同的字體設置我的UINavigationBar。我需要有這樣的畫面:用2種不同的字體設置UINavigationBar

enter image description here

這很容易地創建一個自定義標題,但只有1字體,我發現吸液:

[self.navigationController.navigationBar setTitleTextAttributes: 
@{NSForegroundColorAttributeName:[UIColor redColor], 
       NSFontAttributeName:[UIFont fontWithName:@"Zapfino" size:21] 
    } 
] 

但是,它可能用兩種不同的字體創建一個標題?

回答

3

使用此代碼 -

UIFont *font1 = [UIFont fontWithName:kMyriadProSemiBold size:15]; 

NSDictionary *arialDict = [NSDictionary dictionaryWithObject: font1 forKey:NSFontAttributeName]; 

NSMutableAttributedString *aAttrString1 = [[NSMutableAttributedString alloc] initWithString:@"My" attributes: arialDict]; 

UIFont *font2 = [UIFont fontWithName:kMyriadProRegular size:15]; 

NSDictionary *arialDict2 = [NSDictionary dictionaryWithObject: font2 forKey:NSFontAttributeName]; 

NSMutableAttributedString *aAttrString2 = [[NSMutableAttributedString alloc] initWithString:@"Profile" attributes: arialDict2]; 


[aAttrString1 appendAttributedString:aAttrString2]; 
myProfileLabel.attributedText = aAttrString1; 

可能是你必須改變點點在這段代碼。