IOS项目中的细节处理,如更改状态栏等等
一,状态栏更改为白色
1 在info.plist中添加一个字段:view controller -base status bar 为NO

2 在需要改变状态栏颜色的ViewController中在ViewDidLoad方法中增加:
[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
如果需要在全部View中都变色,可以写在父类的相关方法中,或者写到AppDelegate中。
二 :去除navigationbar 底部黑线 ——亲测可用
if ([self.navigationController.navigationBar respondsToSelector:@selector( setBackgroundImage:forBarMetrics:)]){
NSArray *list=self.navigationController.navigationBar.subviews;
for (id obj in list) {
if ([obj isKindOfClass:[UIImageView class]]) {
UIImageView *imageView=(UIImageView *)obj;
NSArray *list2=imageView.subviews;
for (id obj2 in list2) {
if ([obj2 isKindOfClass:[UIImageView class]]) {
UIImageView *imageView2=(UIImageView *)obj2;
imageView2.hidden=YES;
}
}
}
}
}
1、采用imageNamed方法的图片加载情况
图片资源反复使用到,如按钮背景图片的蓝色背景,这些图片要经常用到,而且占用内存少
2、不应该采用的情况:
(1)图片一般只使用一次,如一些用户的照片资源
(2)图片资源较大,加载到内存后,比较耗费内存资源
四 Unix时间转换
NSNumber *dateStr = [data valueForKey:@"lastLogTime"];
double unixTimeStamp = [dateStr doubleValue];
NSTimeInterval _interval=unixTimeStamp;
NSDate *date = [NSDate dateWithTimeIntervalSince1970:_interval];
NSDateFormatter *_formatter=[[NSDateFormatter alloc]init];
[_formatter setLocale:[NSLocale currentLocale]];
[_formatter setDateFormat:@"dd.MM.yyyy"];
NSString *_date=[_formatter stringFromDate:date];
或者:
[obj printAllPropertys];
nameLabel.text = [obj valueForKey:@"empName"];
orgLabel.text = [obj valueForKey:@"orgName"];
positionLabel.text = [obj valueForKey:@"position"];
cellPhoneLabel.text = [obj valueForKey:@"cellphone"]; NSString *dateNumber = [obj valueForKey:@"lastLogTime"];
NSLog(@"dateNumber%@",dateNumber); NSDateFormatter *dateFormatter=[[NSDateFormatter alloc]init];
[dateFormatter setDateFormat:@"yyyy/mm/dd hh:mm:ss"];
NSTimeZone* timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"];
[dateFormatter setTimeZone:timeZone];
//[dateFormatter setLocale:[NSLocale currentLocale]]; double unixTimeStamp = [dateNumber doubleValue];
NSTimeInterval _interval=unixTimeStamp;
NSDate *date = [NSDate dateWithTimeIntervalSince1970:_interval];
timeStr=[dateFormatter stringFromDate:date];
NSLog(@"loginTime:%@,_interval:%@",timeStr,dateNumber);
五,ios获取app版本号和项目名称
NSString *executableFile = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleExecutableKey]; //获取项目名称
NSString *version = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString*)kCFBundleVersionKey]; //获取项目版本号
浅谈IOS版本号:http://segmentfault.com/a/1190000002423661
NSString *deviceID = (NSString*) [[UIDevice currentDevice] identifierForVendor];//设备id
// NSString *deviceID = [UIApplication sharedApplication] uuid];
NSString *systemVersion = [[UIDevice currentDevice] systemVersion];//系统版本
NSString *systemModel = [[UIDevice currentDevice] model];//是iphone 还是 ipad
NSDictionary *dic = [[NSBundle mainBundle] infoDictionary];//获取info-plist
NSString *appName = [dic objectForKey:@"CFBundleIdentifier"];//获取Bundle identifier
NSString *appVersion = [dic valueForKey:@"CFBundleVersion"];//获取Bundle Version
NSDictionary *userInfo = [[NSDictionary alloc] initWithObjectsAndKeys:
deviceID, @"deviceID",
systemVersion, @"systemVersion",
systemModel, @"systemModel",
appName, @"appName",
appVersion, @"appVersion",nil]; NSLog(@"dic:%@",userInfo);
六,修改SearchBar的取消按钮的字体
///#begin
//
//功能描述:修改SearchBar的Cancel Button 的Title
// 注意点:
// 使用iOS8 SDK ,本次 UISearchBar适用于iOS7(+)版本,如果想要适配iOS6,则需要对应适配iOS6.
// 例如:
// iOS7+ : for(id cc in [searchBar.subviews[0] subviews]){}
// iOS7- : for(id cc in [searchBar subviews]){}
//
///#end
- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar
{
for(id cc in [searchBar.subviews[0] subviews])
{
if([cc isKindOfClass:[UIButton class]])
{
UIButton *btn = (UIButton *)cc;
[btn setTitle:[AppLanguageProcess getLanguageWithKey:@"TEXT_CANCEL"] forState:UIControlStateNormal];
[btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
}
}
}
待续
IOS项目中的细节处理,如更改状态栏等等的更多相关文章
- ios项目中引用其他项目复习
ios项目中引用其他开源项目,今天再次复习了,记个备注. 1. 将开源项目的.xcodeproj拖入项目frameworks 2. Build Phases下 Links Binary With Li ...
- iOS-C文件添加到iOS项目中,运行报错
iOS-C文件添加到iOS项目中,运行报错 问题: 往项目中添加一个空的c文件, 编译运行; 出现2,30个编译错误. 原因: 由于在项目中添加了Pch文件,在文件中所有代码还没有开始运行之前, pc ...
- iOS项目中常见的文件
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,bi ...
- XamarinSQLite教程Xamarin.iOS项目中打开数据库文件
XamarinSQLite教程Xamarin.iOS项目中打开数据库文件 以下是打开MyDocuments.db数据库的具体操作步骤: (1)将Mac电脑上的MyDocuments.db数据库移动到W ...
- XamarinSQLite教程在Xamarin.iOS项目中定位数据库文件
XamarinSQLite教程在Xamarin.iOS项目中定位数据库文件 开发者可以在指定的路径中找到复制的数据库文件,具体的操作步骤如下: (1)单击Mac电脑中Finder菜单中的“前往”|“前 ...
- 在Xamarin.iOS项目中使用预设数据库
在Xamarin.iOS项目中使用预设数据库 当开发者准备好一个预设数据库文件后,就可以将这个数据库文件添加到创建的项目中了.本节将分别在Xamarin.iOS和Xamarin.Android项目中使 ...
- 给iOS项目中添加图片,并通过UIImageView引用和显示该UIImage图片
[问题] 关于iOS/iPhone中的文件选择对话框,用于用户去选择图片等文件 过程中,问题转换为,需要给当前iOS项目中,添加一个图片. 类似于Windows开发中的资源文件,其中图片文件属于资源的 ...
- ios项目中安装和使用CocoaPods
CocoaPods是什么? http://code4app.com/article/cocoapods-install-usage http://blog.csdn.net/jjmm2009/arti ...
- iOS项目中安装和使用 Cocoapods
1.首先我们要打开我们的终端: 2.在终端输入 这条命令 gem sources -l 2.1如果是和我是一样的显示,则镜像已添加,无需更改,如果不一样,则需要进行更改 这里输出的如果是 https ...
随机推荐
- 正向代理 forward proxy、反向代理 reverse proxy、透明代理 transparent proxy nginx反向代理原理和配置讲解 防止外部客户机获取内部内容服务器的重定向 URL 缓存命中
[大型网站技术实践]初级篇:借助Nginx搭建反向代理服务器 - Edison Chou - 博客园http://www.cnblogs.com/edisonchou/p/4126742.html 图 ...
- Windows hackson (rundll32--ADS)
http://www.tuicool.com/articles/AnuqA3 http://www.2cto.com/Article/201507/424713.html http://drops.w ...
- linux rz sz的安装
可以使用yum来安装 yum -y install lrzsz 然后rz就是上传文件,sz就是把文件导到本地.sz 文件名 即可
- Python开发【笔记】:what?进程queue还能生产出线程!
进程queue底层用线程传输数据 import threading import multiprocessing def main(): queue = multiprocessing.Queue() ...
- SQL Server 镜像证书过期处理
转自:https://www.cnblogs.com/trams/archive/2012/01/13/2321637.html SQL Server 镜像证书过期处理 今天镜像中的主服务器进行维护重 ...
- Celery配置Redis数据库保存Return结果状态
使用windows版本 1.于GitHUB下载https://github.com/ServiceStack/redis-windows Window版本,到路径: 2. 运行路径下:D:\redis ...
- inter x86 emulator accelerator(HAXM installer) not compatible with windows
在SDK manager中遇到如下错误:这将导致AVD后期运行和启动方面的问题. 解决办法: 在如下的网址里面下载haxm-windows_v6_2_0这个文件的压缩包,自己手动安装即可.网站如下:点 ...
- 十天精通CSS3(3)
颜色之RGBA RGB是一种色彩标准,是由红(R).绿(G).蓝(B)的变化以及相互叠加来得到各式各样的颜色.RGBA是在RGB的基础上增加了控制alpha透明度的参数. 语法: color:rgba ...
- [py][mx]django get方法返回login页面
get方法返回login.html users/views.py def login(request): if request.method == "POST": pass eli ...
- PAT 1030 Travel Plan[图论][难]
1030 Travel Plan (30)(30 分) A traveler's map gives the distances between cities along the highways, ...