2015-12-12 2 views
0
UIView *sLineBarView = [[UIView alloc]initWithFrame:CGRectMake(0,0,1,20)]; 
     [sCustomTitleView addSubview:sLineBarView]; 
     [sLineBarView TUMMoveToVerticalCenter]; 
     [sLineBarView release]; 

     UIImage *sDropBoxImg= [UIImage imageNamed:@"bt_dropdown"]; 
     UIImageView *sDropDownBox = [[UIImageView alloc] initWithImage: sDropBoxImg]; 
     [sDropDownBox setFrame: CGRectMake(0,30, 92, 58)]; 
     [sDropDownBox setAlpha:1.0f]; 
     sDropDownBox.userInteractionEnabled = YES; 
     sDropDownBox.tag = kDropBoxTag; 

     [sCustomTitleView addSubview:sDropDownBox]; 
     [sDropDownBox release]; 

     UIImage *sRightImage1 = [UIImage imageNamed:@"gnb_bt_menu"]; 

     UIButton *sCustomBarItem0 = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 20,40)]; 
     [sCustomBarItem0 setBackgroundImage:sRightImage1 forState:UIControlStateNormal]; 
     [sCustomTitleView addSubview:sCustomBarItem0]; 
     [sCustomBarItem0 TUMMoveToVerticalCenter]; 

     sViewController.navigationItem.titleView = sCustomTitleView; 

Я хочу навигацияBar titleView выравнивание слева, но без успеха.iOS: Как сделать navigationBar titleView align left

Как сделать навигациюБар titleView выровнять влево?

fream.x = отрицательный

На мой взгляд, это неточное (потому что версия ИОС)

ответ

0

Увеличение sCustomTitleView ширины и проверить или вы можете попробовать этот код в viewDidLoad -.

UILabel* lbl = [[UILabel alloc] initWithFrame:CGRectMake(0,0,200,40)]; 
lbl.textAlignment = NSTextAlignmentLeft; 
lbl.text = @"My Title"; 
self.navigationItem.titleView = lbl; 
+0

Спасибо !! Является ли textAlignment только настройка текста ?? –

+0

Да, вы правы @ KimTaeHun :) –

Смежные вопросы