Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Jul 11, 2025. It is now read-only.

Latest commit

 

History

History
History
89 lines (59 loc) · 2.83 KB

File metadata and controls

89 lines (59 loc) · 2.83 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//
// NodeModelRootNavigationController.m
// NodeModel
//
// Created by YouXianMing on 15/11/10.
// Copyright © 2015年 ZiPeiYi. All rights reserved.
//
#import "NodeModelRootNavigationController.h"
@interface NodeModelRootNavigationController ()
@property (nonatomic, strong) NodeModel *rootNodeModel;
@end
@implementation NodeModelRootNavigationController
- (void)viewDidLoad {
[super viewDidLoad];
[self setup];
}
- (instancetype)initWithRootViewController:(NodeModelViewController *)rootViewController rootNodeModel:(NodeModel *)rootNodeModel {
self = [super initWithRootViewController:rootViewController];
self.rootNodeModel = rootNodeModel;
rootViewController.nodeModel = rootNodeModel;
return self;
}
- (void)setup {
[self.navigationBar setTitleTextAttributes:@{NSFontAttributeName : [UIFont fontWithName:@"AppleSDGothicNeo-Regular" size:18.f]}];
[self.navigationBar setBackgroundImage:[self imageWithFrame:CGRectMake(0, 0, 10, 10) backgroundColor:[[UIColor cyanColor] colorWithAlphaComponent:0.45f]]
forBarPosition:UIBarPositionAny
barMetrics:UIBarMetricsDefault];
[self.navigationBar setShadowImage:[self imageWithFrame:CGRectMake(0, 0, 10, 10) backgroundColor:[UIColor clearColor]]];
}
#pragma mark - 重载父类进行改写
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
//先进入子Controller
[super pushViewController:viewController animated:animated];
//替换掉leftBarButtonItem
if (viewController.navigationItem.leftBarButtonItem == nil && [self.viewControllers count] > 1) {
viewController.navigationItem.leftBarButtonItem =[self customLeftBackButton];
}
}
- (UIBarButtonItem *)customLeftBackButton {
UIImage *image = [UIImage imageNamed:@"NodeModelViewControllerBack_black"];
UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, image.size.width, image.size.height)];
[backButton setBackgroundImage:image forState:UIControlStateNormal];
[backButton addTarget:self action:@selector(popSelf) forControlEvents:UIControlEventTouchUpInside];
return [[UIBarButtonItem alloc] initWithCustomView:backButton];
}
- (void)popSelf {
[self popViewControllerAnimated:YES];
}
- (UIImage *)imageWithFrame:(CGRect)frame backgroundColor:(UIColor *)backgroundColor {
UIImage *image = nil;
UIView *view = [[UIView alloc] initWithFrame:frame];
view.backgroundColor = backgroundColor;
UIGraphicsBeginImageContext(view.frame.size);
[[view layer] renderInContext:UIGraphicsGetCurrentContext()];
image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
@end
Morty Proxy This is a proxified and sanitized view of the page, visit original site.