在最近發佈的Twitter應用更新中,文本從後退按鈕中刪除,並用箭頭替換。它看起來非常好,很簡單,但我無法弄清楚他們是如何做到的。Twitter iOS應用v5.3 UINavigationController後退按鈕
我試圖與iOS 5的UI定製玩耍,但沒有真正運作良好。如果我設置leftBarButtonItem,我可以使它工作,但這意味着我必須在每個視圖控制器中執行此操作,並編寫自己的操作以彈出視圖控制器。有任何想法嗎?提前致謝。
在最近發佈的Twitter應用更新中,文本從後退按鈕中刪除,並用箭頭替換。它看起來非常好,很簡單,但我無法弄清楚他們是如何做到的。Twitter iOS應用v5.3 UINavigationController後退按鈕
我試圖與iOS 5的UI定製玩耍,但沒有真正運作良好。如果我設置leftBarButtonItem,我可以使它工作,但這意味着我必須在每個視圖控制器中執行此操作,並編寫自己的操作以彈出視圖控制器。有任何想法嗎?提前致謝。
它的自定義導航欄和按鈕item.Add驗證碼:
UINavigationBar * bar =[[UINavigationBar alloc]initWithFrame:CGRectMake(0, 0, 320, 44)];
[self.view addSubview:bar];
//Back Button
UIButton *btnback = [UIButton buttonWithType:UIButtonTypeCustom];
[btnback setFrame:CGRectMake(0, 7, 54, 29)];
[btnback setBackgroundImage:[UIImage imageNamed:@"back.png"] forState:UIControlStateNormal];
//UILabel * btnlabel = [[UILabel alloc]initWithFrame:CGRectMake(15, 0, 40, 23)];
//btnlabel.backgroundColor = [UIColor clearColor];
//btnlabel.textColor = [UIColor whiteColor];
//btnlabel.font = [UIFont boldSystemFontOfSize:13];
//btnlabel.text = @"back";
//[btnback addSubview:btnlabel];
//[btnlabel release];
//btnlabel = nil;
[btnback addTarget:self action:@selector(BackAction:) forControlEvents:UIControlEventTouchUpInside];
[bar addSubview:btnback];
[bar release];
無需設置後退按鈕或將其添加爲navigationController的子視圖。您只需要在mainViewController中設置後退按鈕屬性。像
UIBarButtonItem *backButton = [[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Back", nil) style:UIBarButtonItemStyleBordered target:nil action:nil] autorelease];
buttonBack32 = [[UIImage imageNamed:@"back_button.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 13, 0, 4)];
buttonBack24 = [[UIImage imageNamed:@"back_button.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 12, 0, 4)];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:buttonBack32 forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:buttonBack24 forState:UIControlStateNormal barMetrics:UIBarMetricsLandscapePhone];
self.navigationItem.backButton = backButton;
或者你甘蔗遵循本教程http://www.raywenderlich.com/4344/user-interface-customization-in-ios-5