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包版本不 ...
随机推荐
- 批标准化 Batch Normalization
2018-12-05 20:28:15 在机器学习领域有一个很重要的假设,即独立同分布假设,也就是说训练集和测试集是满足相同分布的,这是通过训练数据获得的模型能够在测试集获得好的效果的一个基本保障.而 ...
- 【WPF】Silverlight中的Action与Trigger
最近做的Silverlight项目上用到了大量的拖拽,自动跟随等功能,由于赶时间,加上对Silverlight半生不熟,用的是最简单也是最不好维护的方法.项目忙完了闲下来,想重构一下代码,想起了Tri ...
- ubuntu14.04+MatlabR2014a+caffe
一.下载matlab 1 sudo mkdir /media/matlab 2 sudo mount -o loop [path]MATHWORKS_R2014A.iso /media/matlab ...
- HTML 弹出遮罩层一(遮罩层和内容标签嵌套)
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Django中模型层中ORM的单表操作
ORM概念: MVC或者MVC框架中包括一个重要的部分,就是ORM,它实现了数据模型与数据库的解耦,即数据模型的设计不需要依赖于特定的数据库,通过简单的配置就可以轻松更换数据库,这极大的减轻了开发人员 ...
- python:字典嵌套列表
Python的字典{ }以键值对的形式保存数据,可以以键来访问字典中保存的值而不能用下标访问.字典中几乎可以包含任意的变量,字典,数列,元组.数列也一样. python的列表[ ]与字典不同,列表通过 ...
- Spring Boot系列之配置日志输出等级
我们都知道Spring boot 默认使用 logback作进行日志输出,那么 在配置Spring boot日志输出时有两种方式: 通过application.properties 配置文件的方式来配 ...
- 【Python】Anaconda配置
Anaconda 是一个用于科学计算的Python发行版,支持 Linux.Mac.Windows 系统,提供了包管理与环境管理的功能,可以很方便地解决多版本 Python 并存.切换以及各种第三方包 ...
- Zabbix监控系统
前言: 一个初略自动化运维平台,应该实现以下3个层面自动化: 1.操作系统层面自动化 如果想要万台服务器共舞,没有操作系统这个舞台还怎么舞? 1.1:物理环境: OS预备自动安装(Pxe/KickSt ...
- mac bash 下使用vi 快捷方式——因为没有alt键 所以没有办法 用vi模式也非常方便的
set -o emacs ##切到emacs模式 set -o vi ##切到vi模式 set -o ## 查看当前选项的设置状态 所以你只需要在.bashrc下加入 set -o vi 然后,使用E ...