[英]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.