总结 iOS中一些常用的小方法

一、改变状态栏的颜色:

(1)、在项目 Info plist 里面添加:View controller-based status bar appearance 设置为 NO

(2)、在项目的BaseViewController 里面添加方法:

    // 设置状态栏 颜色为白色

    if (iOS7Later) { // 判断是否是IOS7

        [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:NO];

    }

 

二、设置项目 LaunchScreen 显示的时间:

在app delegate的 方法:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 中添加一个方法:

[NSThread sleepForTimeInterval:3.0];//设置启动页面时间

 

三、系统版本判断的方法:

// 系统的版本判断

#define kSysVersion ([[[UIDevice currentDevice] systemVersion] floatValue])

#define iOS8Later (kSysVersion >= 8.0f)

#define iOS7Later (kSysVersion >= 7.0f)

#define iOS6Later (kSysVersion >= 6.0f) 

#define iOS7 (kSysVersion >= 7.0f && kSysVersion < 8.0f)

 

四、获取到系统appDelegate 实现跳转的方法:

AppDelegate * appDele = (AppDelegate *)[UIApplication sharedApplication].delegate;

TabBarViewController *GHTabBar = [[TabBarViewController alloc] init];

HomeViewController * homeVC = [[HomeViewController alloc] init];

appDele.window.rootViewController = homeVC/GHTabBar;

 

五、有参数的宏定义方法:

#define color(a,b,c,d) [UIColor colorWithRed:a/255.0 green:b/255.0 blue:c/255.0 alpha:d]

#define systemFont(size)      [UIFont systemFontOfSize:size]

#define AppDelegateInstance ((AppDelegate*)([UIApplication sharedApplication].delegate))

 

六、PCH文件的创建方法:

(1)、先创建一个PCH文件

(2)、在Buid settings 里面找到:Apple LLVM - Language 下的:Precompile Prefix Header 将它设置为 YES

    在Prefix Header 中写入他的绝对路径(绝对路径的方法:打开终端。将项目中的.pch文件拖入到终端中即可。然后复制路径)。

 

先写这么多吧。  2016年7月9日 21:53  By 姜艾路。

 

posted @ 2016-07-09 21:53  姜艾路  阅读(123)  评论(0编辑  收藏  举报