iOS 统一配置
1 、统一设置nav标题样式:
- (void)_setNavigationTitle {
NSDictionary *navigationParams = @{NSForegroundColorAttributeName:[UIColor whiteColor],NSFontAttributeName:[UIFont fontWithName:@"FZLBJW--GB1-0" size:]};
[[UINavigationBar appearance]setTitleTextAttributes:navigationParams];
}
2 、统一设置nav相关颜色:
- (void)_setNavigationColor {
[[UINavigationBar appearance] setBarTintColor:[UIColor whiteColor]];
[[UINavigationBar appearance] setTitleTextAttributes:@{NSFontAttributeName:[UIFont fontWithName:@"FZLBJW--GB1-0" size:],NSForegroundColorAttributeName:[UIColor blackColor]}];
[[UINavigationBar appearance] setTintColor:[UIColor blackColor]];
}
3 、统一设置返回按钮:
- (void)_setNavigationBackItem {
UINavigationBar * navigationBar = [UINavigationBar appearance];
UIImage *image = [UIImage imageNamed:@"back"];
image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
navigationBar.backIndicatorImage = image;
navigationBar.backIndicatorTransitionMaskImage = image;
UIBarButtonItem *buttonItem = [UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil];
UIOffset offset;
offset.horizontal = - ;
offset.vertical = ;//不为0在iOS11会造成视图错乱
[buttonItem setBackButtonTitlePositionAdjustment:offset forBarMetrics:UIBarMetricsDefault];
}
4 、统一设置tableViewCell的分割线:
- (void)_setTableViewAppearace {
[[UITableView appearance]setTableFooterView:[UIView new]];
[[UITableView appearance]setSeparatorInset:UIEdgeInsetsZero];
}
5 、统一设置SegmentedControl
UISegmentedControl *appearance = [UISegmentedControl appearance]; //Segmenteg正常背景
[appearance setBackgroundImage:[UIImage imageNamed:@"Segmente.png"]
forState:UIControlStateNormal
barMetrics:UIBarMetricsDefault]; //Segmente选中背景
[appearance setBackgroundImage:[UIImage imageNamed:@"Segmente_a.png"]
forState:UIControlStateSelected
barMetrics:UIBarMetricsDefault]; //Segmente左右都未选中时的分割线
//BarMetrics表示navigation bar的状态,UIBarMetricsDefault 表示portrait状态(44pixel height),UIBarMetricsLandscapePhone 表示landscape状态(32pixel height) [appearance setDividerImage:[UIImage imageNamed:@"Segmente_line.png"]
forLeftSegmentState:UIControlStateNormal
rightSegmentState:UIControlStateNormal
barMetrics:UIBarMetricsDefault]; [appearance setDividerImage:[UIImage imageNamed:@"Segmente_line.png"]
forLeftSegmentState:UIControlStateSelected
rightSegmentState:UIControlStateNormal
barMetrics:UIBarMetricsDefault]; [appearance setDividerImage:[UIImage imageNamed:@"Segmente_line.png"]
forLeftSegmentState:UIControlStateNormal
rightSegmentState:UIControlStateSelected
barMetrics:UIBarMetricsDefault]; //字体
NSDictionary *textAttributes1 = @{UITextAttributeFont: [UIFont systemFontOfSize:],
UITextAttributeTextColor: [UIColor blueColor],
UITextAttributeTextShadowColor: [UIColor whiteColor],
UITextAttributeTextShadowOffset: [NSValue valueWithCGSize:CGSizeMake(, )]}; [appearance setTitleTextAttributes:textAttributes1 forState:]; NSDictionary *textAttributes2 = @{UITextAttributeFont: [UIFont systemFontOfSize:],
UITextAttributeTextColor: [UIColor whiteColor],
UITextAttributeTextShadowColor: [UIColor blackColor],
UITextAttributeTextShadowOffset: [NSValue valueWithCGSize:CGSizeMake(, )]}; [appearance setTitleTextAttributes:textAttributes2 forState:];
6 、统一设置BarButton
//修改导航条上的UIBarButtonItem
UIBarButtonItem *appearance = [UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil nil]; //设置导航栏的字体包括backBarButton和leftBarButton,rightBarButton的字体
NSDictionary *textAttributes = @{UITextAttributeFont: [UIFont systemFontOfSize:],
UITextAttributeTextColor: [UIColor blueColor],
UITextAttributeTextShadowColor: [UIColor whiteColor],
UITextAttributeTextShadowOffset: [NSValue valueWithCGSize:CGSizeMake(, )]}; [appearance setTitleTextAttributes:textAttributes forState:];//forState为0时为下正常状态,为1时为点击状态。 //修改leftBarButton,rightBarButton背景效果
[appearance setBackgroundImage:[UIImage imageNamed:@"navBarButton.png"]
forState:UIControlStateNormal
style:UIBarButtonItemStyleBordered
barMetrics:UIBarMetricsDefault]; [appearance setBackgroundImage:[UIImage imageNamed:@"navBarButton_a.png"]
forState:UIControlStateHighlighted
style:UIBarButtonItemStyleBordered
barMetrics:UIBarMetricsDefault]; //backBarButton需要单独设置背景效果。只能在ios6.0以后才能用
[appearance setBackButtonBackgroundImage:[UIImage imageNamed:@"nav_bg.png"]
forState:
barMetrics:UIBarMetricsDefault]; [appearance setBackButtonBackgroundImage:[UIImage imageNamed:@"work.png"]
forState:
barMetrics:UIBarMetricsDefault]; [appearance setBackButtonTitlePositionAdjustment:UIOffsetMake(, -)
forBarMetrics:UIBarMetricsDefault];
7 、统一设置工具栏:
UIToolbar *appearance = [UIToolbar appearance];
//样式和背景二选一即可,看需求了
//样式(黑色半透明,不透明等)设置
[appearance setBarStyle:UIBarStyleBlackTranslucent];
//背景设置
[appearance setBackgroundImage:[UIImage imageNamed:@"toolbarBg.png"]
forToolbarPosition:UIToolbarPositionAny
barMetrics:UIBarMetricsDefault];
8 、统一设置系统View的tintColor:
关于tintColor的介绍请移步:https://www.jianshu.com/p/4bcaf6349133
UIView.appearance().tintColor = UIColor(named: "Deep Carmine Pink")
你会发现系统默认的颜色从蓝色变为了 Deep Carmine Pink!(backBarItem也是红色只是被覆盖层改变了)
iOS 统一配置的更多相关文章
- 基于ZK构建统一配置中心的方案和实践
背景: 近期使用Zk实现了一个简单的配置管理的小东西,在此开源出来,有兴趣的希望提出您的宝贵意见.如果恰巧您也使用或者接触过类似的东西, 也希望您可以分享下您觉得现在这个项目可以优化和改进的地方. 项 ...
- Android 100多个Styles快速开发布局XML,一行搞定View属性,一键统一配置UI...
Android开发中大量使用XML代码作为界面的布局,使用styles能大幅精简XML代码. 比如下面这个界面从AlertDialog至PlacePickerWindow有19个样式相同的跳转Item ...
- IOS APP配置.plist汇总(转自coolweather )
IOS APP配置.plist汇总(转自coolweather ) 此文转自http://www.cocoachina.com/bbs/read.php?tid=89684&page=1 作者 ...
- JBOSS EAP 6 系列五 Managed domains 管理域最主要的功能是“统一部署,统一配置”
摘要 本文首先介绍Managed Domain的概念,管理域最主要的功能是"统一部署,统一配置".接下来通过一个实例在"统一配置"部分实现一个双机配置起来的域, ...
- .NET Core微服务之基于Apollo实现统一配置中心
Tip: 此篇已加入.NET Core微服务基础系列文章索引 一.关于统一配置中心与Apollo 在微服务架构环境中,项目中配置文件比较繁杂,而且不同环境的不同配置修改相对频繁,每次发布都需要对应修改 ...
- springcloud-spring cloud config统一配置中心
统一配置中心 为什么需要统一配置中心? 统一配置中心顾名思义,就是将配置统一管理,配置统一管理的好处是在日后大规模集群部署服务应用时相同的服务配置一致,日后再修改配置只需要统一修改全部同步,不需要一个 ...
- 多个SpringMVC项目配置统一管理(来自于springCloud的统一配置思路)
因公司项目分多个系统进行开发,而系统架构几乎完全一样,所以同样的配置文件会存在不同的系统中 当其中的某些配置需要修改时,就需要依次把所有系统中相关的配置都修改掉 纯耗时且没技术含量的体力活 所以借鉴S ...
- 基于Apollo实现.NET Core微服务统一配置(测试环境-单机)
一.前言 注:此篇只是为测试环境下的快速入门.后续会给大家带来生产环境下得实战开发. 具体的大家可以去看官方推荐.非常的简单明了.以下介绍引用官方内容: Apollo(阿波罗)是携程框架部门研发的分布 ...
- Android多个Module统一配置相同jar或库的版本号
Android Studio多个Module依赖相同的库时对版本号进行统一配置 在Android项目中,一个项目经常会依赖其他的一个甚至多个库文件,在这种依赖的时候最常见的一个错误就是 jar包版本不 ...
随机推荐
- lua --- 函数的本质
1.lua中的函数是带有此法界定的第一类值. 2.创建一个函数的过程,本质上就是一个创建赋值语句的过程. 常见的创建函数的过程: function fun() print("Hello wo ...
- VNPY思维导图架构
VNPY是使用人数世界第三,国内第一的量化交易框架,封装的接口主要有ctp(期货),wind,xtp(股票)等.内部包含回测.实盘.模拟盘等模块.数据库默认为MongoDB的no-sql数据库,基于p ...
- 第 6 章 存储 - 039 - Data Volume 之 bind mount
Data Volume Data Volume 本质上是 Docker Host 文件系统中的目录或文件,能够直接被 mount 到容器的文件系统中. Data Volume 有以下特点: 1.Dat ...
- 荧光激活细胞分选( FACS)
全称:fluorescence-activated cell sorting 参考: 利用荧光激活细胞分选技术获取荧光蛋白标记肾小球足细胞 荧光激活细胞分离技术在角膜缘干细胞研究中的应用 [求助]急! ...
- java---->lombok.jar的使用
lombok.jar是在看一个项目的代码时遇见的一个“新包”,记录下用法: 1.新建maven工程myfirst,新建一个javabean User,写一个LombokTest类,在pom.xml引入 ...
- java---->Itellij idea报错:错误: 找不到或无法加载主类 main
没有设置好正确的类路径 点击上面圈红色处,在点击Edit Configuration,进入下面设置界面 切换到下面这个界面 红色×消失,运行正常,截图如下
- 安卓音、视频播放功能简单实现 --Android基础
1.音乐播放功能 关键代码: MainActivity.java: package thonlon.example.cn.musicdemowithoutservice; import android ...
- LeetCode--434--字符串中的单词数
问题描述: 统计字符串中的单词个数,这里的单词指的是连续的不是空格的字符. 请注意,你可以假定字符串里不包括任何不可打印的字符. 示例: 输入: "Hello, my name is Joh ...
- Error:Unable to tunnel through proxy. Proxy returns "HTTP/1.1 400 Bad Request"解决方法
出现这个错误的原因主要是因为你的本地Gradle和项目的Gradle地址不一样,要么就是没找到 所以需要更改下你的Gradle地址 如图需要将你的Gradle版本的地址改为,你本地的Gradle地址即 ...
- 【洛谷p1403 】【AHOI2005】约数研究
(有种失踪人口回归的感觉) 约束研究[传送门] (不过好像没有人注意到我这个蒟蒻) 好的不管它啦 最近学数论比较多,所以可能会有好多好多的数论题???(不存在的) 行吧上算法标签: 数论 数论 ...