本文主要是介绍ios设置导航栏背景图片、返回按钮背景、标题颜色等等,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
在ios程序的编写过程中,很多时候我们都要自定义自己的UI,而不是使用cocoatouch中原有的。说起对UI的更改,很多时候我们只是修改一下原有UI的背景啊,颜色之类的,以达到新的要求。在此之前呢,设置UINavigationController的背景颜色,我会使用如下的代码:
首先看.h文件
#import <UIKit/UIKit.h>
@interface UINavigationBar (CustomBar)
- (void)customNavigationBar;
@end
.m文件
#import "UINavigationBar+CustomBar.h"
#import <QuartzCore/QuartzCore.h>
@implementation UINavigationBar (CustomBar)
- (void)customNavigationBar
{if ([self respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)]){CGSize titleSize = self.bounds.size; //获取Navigation Bar的位置和大小UIImage *image = [UIImage imageNamed:@"img_nav_backimg"];UIGraphicsBeginImageContext(titleSize);[image drawInRect:CGRectMake(0, 0, titleSize.width, titleSize.height)];UII
这篇关于ios设置导航栏背景图片、返回按钮背景、标题颜色等等的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!