5
제목 텍스트를 iOS의 UINavigationBar
에 맞게 축소 할 수 있습니까?UINavigationBar 제목 라벨 텍스트
(자동 레이아웃이없는 세로 iPhone 앱용).
제목 표시 줄을 동적으로 설정하고 있지만 텍스트가 너무 길어서 현재 줄임표로 잘라내는 경우가 있습니다.
즉 "이것은 t이다 ..."나는 대신 텍스트를 축소하고 싶습니다.
제목 텍스트를 iOS의 UINavigationBar
에 맞게 축소 할 수 있습니까?UINavigationBar 제목 라벨 텍스트
(자동 레이아웃이없는 세로 iPhone 앱용).
제목 표시 줄을 동적으로 설정하고 있지만 텍스트가 너무 길어서 현재 줄임표로 잘라내는 경우가 있습니다.
즉 "이것은 t이다 ..."나는 대신 텍스트를 축소하고 싶습니다.
자신 만의 타이틀보기를 만들어 만들 수 있습니다. 이 같은
뭔가 :이 도움이
- (void)viewDidLoad
{
[super viewDidLoad];
//Do any additional setup after loading the view, typically from a nib.
UILabel *titleLabelView = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 40)]; //<<---- Actually will be auto-resized according to frame of navigation bar;
[titleLabelView setBackgroundColor:[UIColor clearColor]];
[titleLabelView setTextAlignment: NSTextAlignmentCenter];
[titleLabelView setTextColor:[UIColor whiteColor]];
[titleLabelView setFont:[UIFont systemFontOfSize: 27]]; //<<--- Greatest font size
[titleLabelView setAdjustsFontSizeToFitWidth:YES]; //<<---- Allow shrink
// [titleLabelView setAdjustsLetterSpacingToFitWidth:YES]; //<<-- Another option for iOS 6+
titleLabelView.text = @"This is a Title";
navigationBar.topItem.titleView = titleLabelView;
//....
}
희망.
Xcode 7.1 - Swift 2.0
//Adding Title Label
var navigationTitlelabel = UILabel(frame: CGRectMake(0, 0, 200, 21))
navigationTitlelabel.center = CGPointMake(160, 284)
navigationTitlelabel.textAlignment = NSTextAlignment.Center
navigationTitlelabel.textColor = UIColor.whiteColor()
navigationTitlelabel.text = "WORK ORDER"
self.navigationController!.navigationBar.topItem!.titleView = navigationTitlelabel
감사합니다. 실제로 이미 이와 비슷한 작업을 수행했습니다. UILabel의 카테고리를 사용하여 모든 뷰 컨트롤러에서 빠르게 만들었습니다. – Fogmeister