惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Blog — PlanetScale
Blog — PlanetScale
N
Netflix TechBlog - Medium
博客园 - 司徒正美
The GitHub Blog
The GitHub Blog
G
Google Developers Blog
Stack Overflow Blog
Stack Overflow Blog
博客园_首页
Google DeepMind News
Google DeepMind News
博客园 - 【当耐特】
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Recent Announcements
Recent Announcements
aimingoo的专栏
aimingoo的专栏
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Y
Y Combinator Blog
B
Blog RSS Feed
人人都是产品经理
人人都是产品经理
MongoDB | Blog
MongoDB | Blog
量子位
博客园 - Franky
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Cloudflare Blog
有赞技术团队
有赞技术团队
Jina AI
Jina AI
GbyAI
GbyAI

博客园 - zhoup

文鹏教育_jmeter培训_逻辑控制器_循环取样器 02 jmeter性能测试系列_JForum测试论坛的环境搭建 01 jmeter性能测试系列_Jmeter的体系结构 NSTimer的使用[zhuang] 实战p12文件转pem文件 UIViewContentMode各类型效果 给iOS开发新手送点福利,简述文本属性Attributes的用法 iOS 在tableView上添加button导致按钮没有点击效果和不能滑动的 zhuang xcode 插件地址 AFNnetworking详解 NSRunLoop详解 利用SQL注入漏洞登录后台的实现方法 Xcode 7免证书真机调试 [转]CABasicAnimation用法 zhuang 定制iOS 7中的导航栏和状态栏 zhuang 自定义Xcode代码模板:Code Snippet [zhang] ViewController的生命周期分析和使用 iOS开发--一些UITabBarItem属性的设置[转] UINavigationItem UINavigationBar 关系分析[转]
IOS 设置导航栏全局样式
zhoup · 2016-01-20 · via 博客园 - zhoup
  1. // 1.设置导航栏背景  
  2. UINavigationBar *bar = [UINavigationBar appearance];  
  3. [bar setBackgroundImage:[UIImage resizeImage:@"NavigationBar_Background.png"] forBarMetrics:UIBarMetricsDefault];  
  4. // 状态栏  
  5. [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackOpaque;  
  6.   
  7. // 2.设置导航栏文字属性  
  8. NSMutableDictionary *barAttrs = [NSMutableDictionary dictionary];  
  9. [barAttrs setObject:[UIColor darkGrayColor] forKey:UITextAttributeTextColor];  
  10. [barAttrs setObject:[NSValue valueWithUIOffset:UIOffsetMake(0, 0)] forKey:UITextAttributeTextShadowOffset];  
  11. [bar setTitleTextAttributes:barAttrs];  
  12.   
  13. // 3.按钮  
  14. UIBarButtonItem *item = [UIBarButtonItem appearance];  
  15. [item setBackgroundImage:[UIImage resizeImage:@"BarButtonItem_Normal.png"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];  
  16. [item setBackgroundImage:[UIImage resizeImage:@"BarButtonItem_Pressed.png"] forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];  
  17.   
  18. NSMutableDictionary *itemAttrs = [NSMutableDictionary dictionaryWithDictionary:barAttrs];  
  19. [itemAttrs setObject:[UIFont boldSystemFontOfSize:13] forKey:UITextAttributeFont];  
  20. [item setTitleTextAttributes:itemAttrs forState:UIControlStateNormal];  
  21. [item setTitleTextAttributes:itemAttrs forState:UIControlStateHighlighted];  
  22. [item setTitleTextAttributes:itemAttrs forState:UIControlStateDisabled];  
  23.   
  24. // 4.返回按钮  
  25. [item setBackButtonBackgroundImage:[UIImage resizeImage:@"BarButtonItem_Back_Normal.png"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];  
  26. [item setBackButtonBackgroundImage:[UIImage resizeImage:@"BarButtonItem_Back_Pressed.png"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];  

搞了半天,居然没有发现可以插入Objective-C代码的地方。真郁闷

  1. //  
  2. //  UIImage+Fit.m  
  3. //  SinaWeibo  
  4. //  
  5. //  Created by mj on 13-8-19.  
  6. //  Copyright (c) 2013年 itcast. All rights reserved.  
  7. //  
  8.   
  9. #import "UIImage+Fit.h"  
  10.   
  11. @implementation UIImage (Fit)  
  12.   
  13. #pragma mark 返回拉伸好的图片  
  14. + (UIImage *)resizeImage:(NSString *)imgName {  
  15.     return [[UIImage imageNamed:imgName] resizeImage];  
  16. }  
  17.   
  18. - (UIImage *)resizeImage  
  19. {  
  20.     CGFloat leftCap = self.size.width * 0.5f;  
  21.     CGFloat topCap = self.size.height * 0.5f;  
  22.     return [self stretchableImageWithLeftCapWidth:leftCap topCapHeight:topCap];  
  23. }  
  24.   
  25. - (UIImage *)cut:(CGSize)sizeScale  
  26. {  
  27.     CGFloat width = self.size.width * sizeScale.width;  
  28.     CGFloat height = self.size.height * sizeScale.height;  
  29.     CGFloat x = (self.size.width -  width) * 0.5;  
  30.     CGFloat y = (self.size.height - height) * 0.5;  
  31.     CGRect rect = CGRectMake(x, y, width, height);  
  32.     CGImageRef ref = CGImageCreateWithImageInRect(self.CGImage, rect);  
  33.     return [UIImage imageWithCGImage:ref];  
  34. }  
  35.   
  36. @end  

posted on 2016-01-20 12:26  zhoup  阅读(881)  评论()    收藏  举报