[英]how can i customize the navigation bar?
如何自定義導航欄或在其中添加背景圖像和導航欄按鈕? 請以簡單的方式告訴我不要讓答案難以理解我不是專家嗎? 一步一步解釋。
遺憾的是,您正在尋找的東西並不容易實現。 所需要的技術而不是工作解決方案提醒解決方法它被稱為方法調配,這里是關於如何在導航欄上應用它以獲得自定義背景圖像的教程: http://sebastiancelis.com/2009/ 12/21/添加-背景-圖像-uinavigationbar/
向導航欄添加按鈕相當容易。 假設您的導航欄被實例化為 navigationController:
UIBarButtonItem *yourButton = [[UIBarButtonItem alloc] initWithTitle:@"Hello" style: UIBarButtonStylePlain target:self action:@selector(myTargetMethodSignature:)];
navigationController.navigationItem.rightBarButtonItem = yourButton;
[yourButton release];
希望這可以幫助。 芥末
遵循本教程: iPhone 應用程序 Instagram/Reeder/DailyBooth 如何實現具有可變寬度后退按鈕的自定義 NavigationBars? . 它包括一個源代碼示例。
- (void)drawRect:(CGRect)rect {
/ UIImage *image = [UIImage imageNamed: @"navigation_bar.png"];
UIImage *image = [UIImage imageNamed: @"navigationbarnew2.png"];
[image drawInRect:CGRectMake(0, 0, self.frame.size.width, 44)];
}
@end
UIImage* image3 = [UIImage imageNamed:@"mail-48_24.png"];
CGRect frameimg = CGRectMake(0, 0, image3.size.width, image3.size.height);
UIButton *someButton = [[UIButton alloc] initWithFrame:frameimg];
[someButton setBackgroundImage:image3 forState:UIControlStateNormal];
[someButton addTarget:self action:@selector(sendmail)
forControlEvents:UIControlEventTouchUpInside];
[someButton setShowsTouchWhenHighlighted:YES];
mailbutton =[[UIBarButtonItem alloc] initWithCustomView:someButton];
self.navigationItem.rightBarButtonItem=mailbutton;
[someButton release];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.