Last active
August 8, 2018 05:15
-
-
Save airrons/1ff830a984a57e70c4ada9f8483021bb to your computer and use it in GitHub Desktop.
APP 导航条、状态栏、返回按钮相关
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// vim: syntax=objc | |
//设置返回按钮 | |
UIImage * backImage = [[UIImage imageNamed:@"title_back_icon"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; | |
[UINavigationBar.appearance setBackIndicatorImage:backImage]; | |
[UINavigationBar.appearance setBackIndicatorTransitionMaskImage:backImage]; | |
if(@available(iOS 11, *)) { | |
[[UIBarButtonItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor clearColor]} forState:UIControlStateNormal]; | |
[[UIBarButtonItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor clearColor]} forState:UIControlStateHighlighted]; | |
} else { | |
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(-60, -60) forBarMetrics:UIBarMetricsDefault]; | |
} | |
//设置导航条颜色、图片 | |
UIImage * navigationBarImage = [UIImage imageNamed:@"title_img_back"]; | |
navigationBarImage = [navigationBarImage resizableImageWithCapInsets:UIEdgeInsetsZero resizingMode:UIImageResizingModeStretch]; | |
[UINavigationBar.appearance setBackgroundImage:navigationBarImage forBarMetrics:UIBarMetricsDefault]; | |
//设置导航条文本颜色,按钮颜色 | |
[UINavigationBar.appearance setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}]; | |
[UINavigationBar.appearance setTintColor:[UIColor whiteColor]]; | |
//设置 ToolBar 按钮颜色 | |
[[UIToolbar appearance] setTintColor:[UIColor colorWithHexString:@"FE6655"]]; | |
//白色状态栏(info.plist文件中需要将Status Bar Style 改为 Light) | |
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent; | |
//代码设置RootViewController | |
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; | |
self.window.backgroundColor = [UIColor whiteColor]; | |
[self.window makeKeyAndVisible]; | |
KMHomeViewController * homeViewController = [[KMHomeViewController alloc] init]; | |
KMBaseNavigationController * homeNavi = [[KMBaseNavigationController alloc] initWithRootViewController:homeViewController]; | |
self.window.rootViewController = homeNavi; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment