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 ...
随机推荐
- ios系统(苹果手机)按钮显示为圆角和渐变的问题
按钮在安卓手机上显示正常,但在苹果手机上会显示如下: 解决办法:给该按钮的样式加上:-webkit-appearance:none;这样按钮就会显示正常
- Linux虚拟机安装(CentOS 6.5,图文详解,需要自查)
Linux虚拟机的安装(图文详解) 下篇会接续Hadoop集群安装(以此为基础) 一.安装准备 VMWorkstation.linux系统镜像(以下以CentOS6.5为例) 二.安装过程详解 关闭防 ...
- jquery常用选择器和常用方法
基本选择器 $(”#myDiv”) //匹配唯一的具有此id值的元素 $(”div”) //匹配指定名称的所有元素 $(”.myClass”) //匹配具有此class样式值的所有元素 $(”*”) ...
- HDU 1010 Tempter of the Bone(深度+剪枝)
http://acm.hdu.edu.cn/showproblem.php?pid=1010 题意:就是给出了一个迷宫,小狗必须经过指定的步数到达出口,并且每个格子只能走一次. 首先先来介绍一下奇偶性 ...
- 关于js代码中与或运算符||&&的妙用
看bootstrap时看到如下一行JavaScript代码产生了疑惑. return window.pageYOffset || e.scrollTop ||在这里的作用是什么呢? 首先明确概念,在j ...
- etcd第三集
简单说下golang的etcd接口例子.etcd api有v2(http+json)和v3(grpc)两个版本,目前大家都用v2,所以... v2: https://github.com/coreos ...
- WPF 重新启动该程序
// Restart current process Method 1 System.Windows.Forms.Application.Restart(); Application.Current. ...
- notepad++
plugin-manager 先要保证plugin-manager是最新的,然后才能下载其它的插件进行安装. compare插件,文件对比工具
- 在datagrid中实现单击行选择整行
首先添加列:<asp:ButtonColumn Text="选择" CommandName="Select" Visible="False&qu ...
- ArcEngine :The XY domain on the spatial reference is not set or invalid错误
在创建数据集的时候,提示The XY domain on the spatial reference is not set or invalid错误. 原因:未设置空间参考(ISpatialRefer ...