2016-08-25 4 views
0

発音記号を含むナビゲーションアイテムのタイトルテキストにカスタムフォントと大文字のテキストを使用しています。問題は、発音記号が上から切り取られていることです。おそらく、タイトルラベルの高さが間違っているためです。UINavigationBar navigationItemタイトルの高さ

タイトルのラベルの高さに問題はありますか?または、タイトルラベルに直接アクセスして、sizeToFitのようなことをするか、フレームなどを変更します。

// custom font settings 
NSDictionary *attr = @{ 
         NSFontAttributeName: [UIFont fontWithName:@"FishmongerK-XCondLight" size:23.0], 
         NSForegroundColorAttributeName: [UIColor whiteColor] 
         }; 

[[UINavigationBar appearance] setTitleTextAttributes: attr]; 

// then setting of title 
self.navigationItem.title = [NSLocalizedString(@"Oblíbené", nil) uppercaseString]; 

小さいフォントサイズを試しても、発音区別記号は上から切り捨てられます。

答えて

0
-(void)setCustomNavTitle:(NSString*)title andDescription:(NSString*)desc { 

NSString * locname = [NSString stringWithFormat:@"%@\n", title]; 
NSString * cityname = [NSString stringWithFormat:@"%@", desc]; 
NSString * text = [NSString stringWithFormat:@"%@%@", [locname capitalizedString], cityname]; 

NSDictionary *attribs = @{ 
          NSForegroundColorAttributeName:[UIColor colorWithHexString:@"222222"], 
          NSFontAttributeName: [UIFont fontWithName:[[Variables getInstance] HelveticaNeue] size:14] 
          }; 
NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:text attributes:attribs]; 

NSRange range = [text rangeOfString:cityname]; 
[attributedText setAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithHexString:@"222222"], 
           NSFontAttributeName:[UIFont fontWithName:[[Variables getInstance] HelveticaNeueLight] size:14]} range:range]; 

UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 120, 44)]; 
titleLabel.font = [UIFont fontWithName:[[Variables getInstance] HelveticaNeueMedium] size:15]; 
titleLabel.attributedText = attributedText; 
titleLabel.backgroundColor = [UIColor clearColor]; 
titleLabel.textAlignment = NSTextAlignmentCenter; 
titleLabel.numberOfLines=0; 
titleLabel.lineBreakMode = NSLineBreakByWordWrapping; 
titleLabel.textColor = [UIColor blackColor]; 
self.navigationItem.titleView = titleLabel; 

}

関連する問題