-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathJBSWelcomeViewController.m
More file actions
76 lines (57 loc) · 3.1 KB
/
JBSWelcomeViewController.m
File metadata and controls
76 lines (57 loc) · 3.1 KB
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
#import "JBSWelcomeViewController.h"
#import "JBSPasswordManager.h"
#import "JBSDummyViewController.h"
@interface JBSWelcomeViewController ()
@property (nonatomic, strong) NSLayoutConstraint *centerYConstraint;
@end
@implementation JBSWelcomeViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
[[JBSPasswordManager sharedManager] passwordChanged];
self.navigationItem.hidesBackButton = YES;
UILabel *welcomeLabel = [[UILabel alloc] init];
welcomeLabel.translatesAutoresizingMaskIntoConstraints = NO;
welcomeLabel.textAlignment = NSTextAlignmentCenter;
welcomeLabel.text = [NSString stringWithFormat:@"Welcome to your jailbroken %@", [UIDevice currentDevice].model];
welcomeLabel.numberOfLines = 0;
welcomeLabel.font = [UIFont systemFontOfSize:34.0 weight:UIFontWeightBold];
[self.view addSubview:welcomeLabel];
[welcomeLabel.leadingAnchor constraintEqualToAnchor:self.view.readableContentGuide.leadingAnchor].active = YES;
[welcomeLabel.trailingAnchor constraintEqualToAnchor:self.view.readableContentGuide.trailingAnchor].active = YES;
self.centerYConstraint = [welcomeLabel.centerYAnchor constraintEqualToAnchor:self.view.centerYAnchor];
self.centerYConstraint.active = YES;
UIButton *getStartedButton = [UIButton buttonWithType:UIButtonTypeSystem];
getStartedButton.translatesAutoresizingMaskIntoConstraints = NO;
[getStartedButton setTitle:@"Get Started" forState:UIControlStateNormal];
getStartedButton.titleLabel.font = [UIFont systemFontOfSize:23.0 weight:UIFontWeightRegular];
[getStartedButton addTarget:self action:@selector(getStartedButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:getStartedButton];
[getStartedButton.centerXAnchor constraintEqualToAnchor:self.view.centerXAnchor].active = YES;
[getStartedButton.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor].active = YES;
[getStartedButton.heightAnchor constraintEqualToAnchor:self.view.heightAnchor multiplier:0.5].active = YES;
}
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
self.centerYConstraint.constant = -self.navigationController.navigationBar.bounds.size.height - 15.0;
}
-(void)getStartedButtonTapped:(UIButton *)sender {
__weak UIViewController *presentingVC = self.presentingViewController;
[self.presentingViewController dismissViewControllerAnimated:YES completion:^{
if ([presentingVC isKindOfClass:[JBSDummyViewController class]]) {
presentingVC.view.hidden = YES;
[presentingVC.view removeFromSuperview];
UIWindow *window = [presentingVC valueForKey:@"window"];
window.hidden = YES;
}
}];
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end