IOS 设置导航栏全局样式
- // 1.设置导航栏背景
- UINavigationBar *bar = [UINavigationBar appearance];
- [bar setBackgroundImage:[UIImage resizeImage:@"NavigationBar_Background.png"] forBarMetrics:UIBarMetricsDefault];
- // 状态栏
- [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackOpaque;
- // 2.设置导航栏文字属性
- NSMutableDictionary *barAttrs = [NSMutableDictionary dictionary];
- [barAttrs setObject:[UIColor darkGrayColor] forKey:UITextAttributeTextColor];
- [barAttrs setObject:[NSValue valueWithUIOffset:UIOffsetMake(0, 0)] forKey:UITextAttributeTextShadowOffset];
- [bar setTitleTextAttributes:barAttrs];
- // 3.按钮
- UIBarButtonItem *item = [UIBarButtonItem appearance];
- [item setBackgroundImage:[UIImage resizeImage:@"BarButtonItem_Normal.png"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
- [item setBackgroundImage:[UIImage resizeImage:@"BarButtonItem_Pressed.png"] forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
- NSMutableDictionary *itemAttrs = [NSMutableDictionary dictionaryWithDictionary:barAttrs];
- [itemAttrs setObject:[UIFont boldSystemFontOfSize:13] forKey:UITextAttributeFont];
- [item setTitleTextAttributes:itemAttrs forState:UIControlStateNormal];
- [item setTitleTextAttributes:itemAttrs forState:UIControlStateHighlighted];
- [item setTitleTextAttributes:itemAttrs forState:UIControlStateDisabled];
- // 4.返回按钮
- [item setBackButtonBackgroundImage:[UIImage resizeImage:@"BarButtonItem_Back_Normal.png"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
- [item setBackButtonBackgroundImage:[UIImage resizeImage:@"BarButtonItem_Back_Pressed.png"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
搞了半天,居然没有发现可以插入Objective-C代码的地方。真郁闷
- //
- // UIImage+Fit.m
- // SinaWeibo
- //
- // Created by mj on 13-8-19.
- // Copyright (c) 2013年 itcast. All rights reserved.
- //
- #import "UIImage+Fit.h"
- @implementation UIImage (Fit)
- #pragma mark 返回拉伸好的图片
- + (UIImage *)resizeImage:(NSString *)imgName {
- return [[UIImage imageNamed:imgName] resizeImage];
- }
- - (UIImage *)resizeImage
- {
- CGFloat leftCap = self.size.width * 0.5f;
- CGFloat topCap = self.size.height * 0.5f;
- return [self stretchableImageWithLeftCapWidth:leftCap topCapHeight:topCap];
- }
- - (UIImage *)cut:(CGSize)sizeScale
- {
- CGFloat width = self.size.width * sizeScale.width;
- CGFloat height = self.size.height * sizeScale.height;
- CGFloat x = (self.size.width - width) * 0.5;
- CGFloat y = (self.size.height - height) * 0.5;
- CGRect rect = CGRectMake(x, y, width, height);
- CGImageRef ref = CGImageCreateWithImageInRect(self.CGImage, rect);
- return [UIImage imageWithCGImage:ref];
- }
- @end
IOS 设置导航栏全局样式的更多相关文章
- iOS设置导航栏样式(UINavigationController)
//设置导航栏baritem和返回baiitem样式 UIBarButtonItem *barItem = [UIBarButtonItem appearance]; //去掉返回按钮上的字 [bar ...
- IOS 设置导航栏
//设置导航栏的标题 self.navigationItem setTitle:@"我的标题"; //设置导航条标题属性:字体大小/字体颜色…… /*设置头的属性:setTitle ...
- iOS 设置导航栏之二(设置导航栏的颜色、文字的颜色、左边按钮的文字及颜色)
#import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicati ...
- iOS 设置导航栏的颜色和导航栏上文字的颜色
#import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDelegate> @pr ...
- iOS 设置导航栏全透明
- (void)viewWillAppear:(BOOL)animated{ //设置导航栏背景图片为一个空的image,这样就透明了 [self.navigationController.navig ...
- ios 设置导航栏背景色
//设置导航栏背景色 如果上面的不好用 就用下面的 [self.navigationController.navigationBar setBackgroundImage:[UIImage image ...
- IOS设置导航栏字体大小及颜色
方法一: 自定义视图,定义一个lable,相关属性在lable里设置 核心方法: self.navigationItem.titleView = titleLabel; 方法二:用系统方法直接设置 [ ...
- iOS设置导航栏标题
方法一:在UIViewController中设置self.title. 方法二:设置self.navigationItem.titleView.
- iOS设置导航栏透明度
As I support Colin's answer, I want to give you an additional hint to customize the appearance of an ...
随机推荐
- junit单元测试(keeps the bar green to keeps the code clean)
error是程序错误,failure是测试错误. junit概要: JUnit是由 Erich Gamma (设计模式的创始人)和 Kent Beck (敏捷开发的创始人之一)编写的一个回归测试框架( ...
- help man info 三个的区别
“--help”选项 “--help”是一个工具选项,大部分的GNU工具都具备这个选项,“--help”选项可以用来显示一些工具的信息 “man”工具 Man工具可以显示系统手册页中的内容,这些内容大 ...
- Binary Tree Postorder Traversal
Given a binary tree, return the postorder traversal of its nodes' values. For example:Given binary t ...
- Python列表
列表不同于字符串和元组:列表是可变的--可以改变列表的内容 1.列表函数 1.list(x)函数(其实是一种类型,而不是一个真正意义上的函数) 转化为列表,其中x可以是其他序列 可以用''.join( ...
- 开始写Effective系列总结一些前端的心得
确实是没有时间整理以及总结和发表自己的感慨.难得中秋银行的事情搞完了自己清闲3天,是时候总结一下从大公司做.NET PC 端网站的开发到现在做移动互联网的银行及政府微信公众号的开发的感触.当时自己的选 ...
- h5调用摄像头
<!DOCTYPE html><html lang="zh-CN"><head> <meta charset="UTF-8&qu ...
- python 模拟用户登录代码
需求:输入用户名,判断用户是否被锁定,锁定则退出,否则进入密码验证,输入三次错误密码之后此用户被锁定. userlist.txt里,用":"将用户名.密码.状态码分开: [root ...
- Could not load java.net.BindException错误解决
出现了错误异常:信息: Illegal access: this web application instance has been stopped already. Could not load ...
- SSH基于Hibernate eventListener 事件侦听器的操作日志自动保存到数据库
在spring xml配置文件中添加配置,包含:model.listener 在model中增加需要写入数据库对应表的model 在auditLog.xml配置文件中配置自己项目中,需要进行日志记录的 ...
- 64位系统里的IIS运行32位ODP.NET的方法
在64位Win7里的IIS里部署使用了ODP.NET的网站,Oracle的版本是11.20.3.20.直接部署会提示错误:在64位环境里使用了32位的程序.自己折腾了两天,最后才从别人的博客里找到解决 ...