Skip to content

Commit

Permalink
工程添加图片,review代码
Browse files Browse the repository at this point in the history
  • Loading branch information
ChavezChen committed Jan 27, 2018
1 parent 542e559 commit 1e8c2c7
Show file tree
Hide file tree
Showing 28 changed files with 227 additions and 26 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "CWLateralSlide/CWDrawerTransition.m"
timestampString = "537636427.794027"
timestampString = "538710973.571124"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "165"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
Expand Down
6 changes: 6 additions & 0 deletions CWLateralSlideDemo/Assets.xcassets/tabbar/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "tab_wenzhen.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"template-rendering-intent" : "original"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "tab_wenzhen_pre.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"template-rendering-intent" : "original"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "tab_zhushou.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"template-rendering-intent" : "original"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "tab_zhushou_pre.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"template-rendering-intent" : "original"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "yitiji_data_nav_bg.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 29 additions & 10 deletions CWLateralSlideDemo/Clasess/NavigationController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
73 changes: 59 additions & 14 deletions CWLateralSlideDemo/Clasess/TabbarController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}


Expand Down
1 change: 0 additions & 1 deletion CWLateralSlideDemo/Clasess/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1e8c2c7

Please sign in to comment.