diff --git a/.DS_Store b/.DS_Store index 784f299..8869b36 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/CWLateralSlideDemo.xcodeproj/project.xcworkspace/xcuserdata/chenwang.xcuserdatad/UserInterfaceState.xcuserstate b/CWLateralSlideDemo.xcodeproj/project.xcworkspace/xcuserdata/chenwang.xcuserdatad/UserInterfaceState.xcuserstate index 8f9aca5..0d25f8b 100644 Binary files a/CWLateralSlideDemo.xcodeproj/project.xcworkspace/xcuserdata/chenwang.xcuserdatad/UserInterfaceState.xcuserstate and b/CWLateralSlideDemo.xcodeproj/project.xcworkspace/xcuserdata/chenwang.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/CWLateralSlideDemo.xcodeproj/xcuserdata/chenwang.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/CWLateralSlideDemo.xcodeproj/xcuserdata/chenwang.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 9f31c1d..53e2afc 100644 --- a/CWLateralSlideDemo.xcodeproj/xcuserdata/chenwang.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/CWLateralSlideDemo.xcodeproj/xcuserdata/chenwang.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -20,7 +20,7 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "CWLateralSlide/CWDrawerTransition.m" - timestampString = "537636427.794027" + timestampString = "538710973.571124" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "165" diff --git a/CWLateralSlideDemo/Assets.xcassets/AppIcon.appiconset/Contents.json b/CWLateralSlideDemo/Assets.xcassets/AppIcon.appiconset/Contents.json index 1d060ed..d8db8d6 100644 --- a/CWLateralSlideDemo/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/CWLateralSlideDemo/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -84,6 +84,11 @@ "idiom" : "ipad", "size" : "83.5x83.5", "scale" : "2x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" } ], "info" : { diff --git a/CWLateralSlideDemo/Assets.xcassets/tabbar/Contents.json b/CWLateralSlideDemo/Assets.xcassets/tabbar/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/CWLateralSlideDemo/Assets.xcassets/tabbar/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_wenzhen.imageset/Contents.json b/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_wenzhen.imageset/Contents.json new file mode 100644 index 0000000..26b71ec --- /dev/null +++ b/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_wenzhen.imageset/Contents.json @@ -0,0 +1,26 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "tab_wenzhen.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "tab_wenzhen@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "tab_wenzhen@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + }, + "properties" : { + "template-rendering-intent" : "original" + } +} \ No newline at end of file diff --git a/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_wenzhen.imageset/tab_wenzhen.png b/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_wenzhen.imageset/tab_wenzhen.png new file mode 100644 index 0000000..b2194a4 Binary files /dev/null and b/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_wenzhen.imageset/tab_wenzhen.png differ diff --git a/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_wenzhen.imageset/tab_wenzhen@2x.png b/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_wenzhen.imageset/tab_wenzhen@2x.png new file mode 100644 index 0000000..b2194a4 Binary files /dev/null and b/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_wenzhen.imageset/tab_wenzhen@2x.png differ diff --git a/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_wenzhen.imageset/tab_wenzhen@3x.png b/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_wenzhen.imageset/tab_wenzhen@3x.png new file mode 100644 index 0000000..c83785d Binary files /dev/null and b/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_wenzhen.imageset/tab_wenzhen@3x.png differ diff --git a/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_wenzhen_pre.imageset/Contents.json b/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_wenzhen_pre.imageset/Contents.json new file mode 100644 index 0000000..8be02b8 --- /dev/null +++ b/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_wenzhen_pre.imageset/Contents.json @@ -0,0 +1,26 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "tab_wenzhen_pre.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "tab_wenzhen_pre@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "tab_wenzhen_pre@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + }, + "properties" : { + "template-rendering-intent" : "original" + } +} \ No newline at end of file diff --git a/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_wenzhen_pre.imageset/tab_wenzhen_pre.png b/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_wenzhen_pre.imageset/tab_wenzhen_pre.png new file mode 100644 index 0000000..28cfe2c Binary files /dev/null and b/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_wenzhen_pre.imageset/tab_wenzhen_pre.png differ diff --git a/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_wenzhen_pre.imageset/tab_wenzhen_pre@2x.png b/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_wenzhen_pre.imageset/tab_wenzhen_pre@2x.png new file mode 100644 index 0000000..28cfe2c Binary files /dev/null and b/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_wenzhen_pre.imageset/tab_wenzhen_pre@2x.png differ diff --git a/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_wenzhen_pre.imageset/tab_wenzhen_pre@3x.png b/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_wenzhen_pre.imageset/tab_wenzhen_pre@3x.png new file mode 100644 index 0000000..33f04ec Binary files /dev/null and b/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_wenzhen_pre.imageset/tab_wenzhen_pre@3x.png differ diff --git a/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_zhushou.imageset/Contents.json b/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_zhushou.imageset/Contents.json new file mode 100644 index 0000000..fa55314 --- /dev/null +++ b/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_zhushou.imageset/Contents.json @@ -0,0 +1,26 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "tab_zhushou.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "tab_zhushou@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "tab_zhushou@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + }, + "properties" : { + "template-rendering-intent" : "original" + } +} \ No newline at end of file diff --git a/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_zhushou.imageset/tab_zhushou.png b/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_zhushou.imageset/tab_zhushou.png new file mode 100644 index 0000000..9d702bc Binary files /dev/null and b/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_zhushou.imageset/tab_zhushou.png differ diff --git a/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_zhushou.imageset/tab_zhushou@2x.png b/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_zhushou.imageset/tab_zhushou@2x.png new file mode 100644 index 0000000..9d702bc Binary files /dev/null and b/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_zhushou.imageset/tab_zhushou@2x.png differ diff --git a/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_zhushou.imageset/tab_zhushou@3x.png b/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_zhushou.imageset/tab_zhushou@3x.png new file mode 100644 index 0000000..8eb7585 Binary files /dev/null and b/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_zhushou.imageset/tab_zhushou@3x.png differ diff --git a/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_zhushou_pre.imageset/Contents.json b/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_zhushou_pre.imageset/Contents.json new file mode 100644 index 0000000..fd0fd26 --- /dev/null +++ b/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_zhushou_pre.imageset/Contents.json @@ -0,0 +1,26 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "tab_zhushou_pre.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "tab_zhushou_pre@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "tab_zhushou_pre@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + }, + "properties" : { + "template-rendering-intent" : "original" + } +} \ No newline at end of file diff --git a/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_zhushou_pre.imageset/tab_zhushou_pre.png b/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_zhushou_pre.imageset/tab_zhushou_pre.png new file mode 100644 index 0000000..10bd70a Binary files /dev/null and b/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_zhushou_pre.imageset/tab_zhushou_pre.png differ diff --git a/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_zhushou_pre.imageset/tab_zhushou_pre@2x.png b/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_zhushou_pre.imageset/tab_zhushou_pre@2x.png new file mode 100644 index 0000000..10bd70a Binary files /dev/null and b/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_zhushou_pre.imageset/tab_zhushou_pre@2x.png differ diff --git a/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_zhushou_pre.imageset/tab_zhushou_pre@3x.png b/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_zhushou_pre.imageset/tab_zhushou_pre@3x.png new file mode 100644 index 0000000..c39d441 Binary files /dev/null and b/CWLateralSlideDemo/Assets.xcassets/tabbar/tab_zhushou_pre.imageset/tab_zhushou_pre@3x.png differ diff --git a/CWLateralSlideDemo/Assets.xcassets/yitiji_date_nav_bg.imageset/Contents.json b/CWLateralSlideDemo/Assets.xcassets/yitiji_date_nav_bg.imageset/Contents.json new file mode 100644 index 0000000..a6be1c5 --- /dev/null +++ b/CWLateralSlideDemo/Assets.xcassets/yitiji_date_nav_bg.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "yitiji_data_nav_bg.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "yitiji_date_nav_bg@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "yitiji_date_nav_bg@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/CWLateralSlideDemo/Assets.xcassets/yitiji_date_nav_bg.imageset/yitiji_data_nav_bg.png b/CWLateralSlideDemo/Assets.xcassets/yitiji_date_nav_bg.imageset/yitiji_data_nav_bg.png new file mode 100644 index 0000000..8278420 Binary files /dev/null and b/CWLateralSlideDemo/Assets.xcassets/yitiji_date_nav_bg.imageset/yitiji_data_nav_bg.png differ diff --git a/CWLateralSlideDemo/Assets.xcassets/yitiji_date_nav_bg.imageset/yitiji_date_nav_bg@2x.png b/CWLateralSlideDemo/Assets.xcassets/yitiji_date_nav_bg.imageset/yitiji_date_nav_bg@2x.png new file mode 100644 index 0000000..8278420 Binary files /dev/null and b/CWLateralSlideDemo/Assets.xcassets/yitiji_date_nav_bg.imageset/yitiji_date_nav_bg@2x.png differ diff --git a/CWLateralSlideDemo/Assets.xcassets/yitiji_date_nav_bg.imageset/yitiji_date_nav_bg@3x.png b/CWLateralSlideDemo/Assets.xcassets/yitiji_date_nav_bg.imageset/yitiji_date_nav_bg@3x.png new file mode 100644 index 0000000..d15b64f Binary files /dev/null and b/CWLateralSlideDemo/Assets.xcassets/yitiji_date_nav_bg.imageset/yitiji_date_nav_bg@3x.png differ diff --git a/CWLateralSlideDemo/Clasess/NavigationController.m b/CWLateralSlideDemo/Clasess/NavigationController.m index c0781d2..f76027d 100644 --- a/CWLateralSlideDemo/Clasess/NavigationController.m +++ b/CWLateralSlideDemo/Clasess/NavigationController.m @@ -14,21 +14,40 @@ @interface NavigationController () @implementation NavigationController + ++ (void)initialize{ + + NSMutableDictionary *attrs = [NSMutableDictionary dictionary]; + attrs[NSFontAttributeName] = [UIFont systemFontOfSize:18]; // 字体大小 + attrs[NSForegroundColorAttributeName] = [UIColor blackColor]; // 颜色 + + UINavigationBar *naviBar = [UINavigationBar appearance]; + [naviBar setTitleTextAttributes:attrs]; +// [naviBar setBackgroundImage:[UIImage imageNamed:@"yitiji_date_nav_bg"] forBarMetrics:UIBarMetricsDefault]; +} + + - (void)viewDidLoad { [super viewDidLoad]; - // Do any additional setup after loading the view. - self.navigationBar.translucent = NO; -} -- (void)viewDidLayoutSubviews { - [super viewDidLayoutSubviews]; -// NSLog(@"=============%@",NSStringFromCGRect(self.navigationBar.frame)); - } -- (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. +- (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; +// return; + // 解决iOS11界面缩放后导航栏空出状态栏的空隙的问题 + if (@available(iOS 11, *)) { // xcode9新特性 可以这样判断,xcode9以下只能用UIDevice systemVersion 来判断 + UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"]; + CGFloat statusH = CGRectGetHeight(statusBar.frame); + for (UIView *view in self.navigationBar.subviews) { + if ([NSStringFromClass([view class]) isEqualToString:@"_UIBarBackground"]) { + CGRect frame = view.frame; + frame.size.height = 44 + statusH; + frame.origin.y = -statusH; + view.frame = frame; + } + } + } } - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{ diff --git a/CWLateralSlideDemo/Clasess/TabbarController.m b/CWLateralSlideDemo/Clasess/TabbarController.m index 82adc70..951166c 100644 --- a/CWLateralSlideDemo/Clasess/TabbarController.m +++ b/CWLateralSlideDemo/Clasess/TabbarController.m @@ -10,36 +10,81 @@ #import "ViewController.h" #import "NavigationController.h" +#define iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO) + @interface TabbarController () @end @implementation TabbarController -- (void)viewDidLoad { - [super viewDidLoad]; ++ (void)initialize{ + // 设置tabbarItem统一样式 + NSMutableDictionary *attrs = [NSMutableDictionary dictionary]; + attrs[NSFontAttributeName] = [UIFont systemFontOfSize:11]; + attrs[NSForegroundColorAttributeName] = [UIColor colorWithRed:87/255.0 green:125/255.0 blue:130/255.0 alpha:1.0]; + NSMutableDictionary *selectedAttrs = [NSMutableDictionary dictionary]; + selectedAttrs[NSFontAttributeName] = attrs[NSFontAttributeName]; + selectedAttrs[NSForegroundColorAttributeName] = [UIColor colorWithRed:12/255.0 green:204/255.0 blue:207/255.0 alpha:1.0]; - ViewController *vc1 = [[ViewController alloc] init]; - NavigationController *nav1 = [[NavigationController alloc] initWithRootViewController:vc1]; - vc1.title = @"聊天"; -// vc1.view.backgroundColor = [UIColor yellowColor]; - [self addChildViewController:nav1]; + UITabBarItem *item = [UITabBarItem appearance]; + [item setTitleTextAttributes:attrs forState:UIControlStateNormal]; + [item setTitleTextAttributes:selectedAttrs forState:UIControlStateSelected]; +} + +- (void)viewDidLoad { + [super viewDidLoad]; + self.view.backgroundColor = [UIColor whiteColor]; + + [self setupChildVc:[[ViewController alloc] init] title:@"聊天" image:@"tab_zhushou" selectedImage:@"tab_zhushou_pre"]; + + [self setupChildVc:[[ViewController alloc] init] title:@"通讯录" image:@"tab_wenzhen" selectedImage:@"tab_wenzhen_pre"]; - ViewController *vc2 = [[ViewController alloc] init]; - NavigationController *nav2 = [[NavigationController alloc] initWithRootViewController:vc2]; - vc2.title = @"通讯录"; - vc2.view.backgroundColor = [UIColor cyanColor]; - [self addChildViewController:nav2]; +} + +- (void)setupChildVc:(UIViewController *)vc title:(NSString *)title image:(NSString *)image selectedImage:(NSString *)selectedImage +{ + // 设置文字和图片 + vc.navigationItem.title = title; + vc.tabBarItem.title = title; + vc.tabBarItem.image = [UIImage imageNamed:image]; + vc.tabBarItem.selectedImage = [UIImage imageNamed:selectedImage]; + NavigationController *nav = [[NavigationController alloc] initWithRootViewController:vc]; + [self addChildViewController:nav]; } + +- (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; +// return; + if (!iPhoneX) return; + + for (UIView *view in self.tabBar.subviews) { + if ([NSStringFromClass([view class]) isEqualToString:@"UITabBarButton"]) { + CGRect frame = view.frame; + frame.size.height = 48; + view.frame = frame; + NSLayoutConstraint *heightConstraint = [NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:0.0 constant:48]; + heightConstraint.priority = UILayoutPriorityDefaultHigh; +// [view addConstraint:heightConstraint]; + } + } +} + - (void)viewDidLayoutSubviews { [super viewDidLayoutSubviews]; -// NSLog(@".............%@",NSStringFromCGRect(self.view.frame)); -// NSLog(@"%@",NSStringFromCGAffineTransform(self.view.transform) ); + + if (!iPhoneX) return; + CGRect frame = self.tabBar.frame; + CGFloat h = 83 - frame.size.height; + frame.size.height += h; + frame.origin.y -= h; + self.tabBar.frame = frame; + } diff --git a/CWLateralSlideDemo/Clasess/ViewController.m b/CWLateralSlideDemo/Clasess/ViewController.m index 96d858b..48f8cf9 100644 --- a/CWLateralSlideDemo/Clasess/ViewController.m +++ b/CWLateralSlideDemo/Clasess/ViewController.m @@ -178,7 +178,6 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath #pragma mark - setupUI - (void)setupUI { - self.tabBarController.view.backgroundColor = [UIColor whiteColor]; if ([self respondsToSelector:@selector(edgesForExtendedLayout)]) { self.edgesForExtendedLayout = UIRectEdgeNone;