-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathJBSSetupViewController.m
More file actions
129 lines (96 loc) · 6.69 KB
/
JBSSetupViewController.m
File metadata and controls
129 lines (96 loc) · 6.69 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#import "JBSSetupViewController.h"
@interface JBSSetupViewController ()
@property (nonatomic, strong) NSLayoutConstraint *continueHeightConstraint;
@property (nonatomic, strong) NSLayoutConstraint *scrollViewBottomConstraint;
@property (nonatomic, strong) UIView *scrollViewContentView;
@end
@implementation JBSSetupViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.hideContinueButton = NO;
self.continueButton = [JBSContinueButton buttonWithType:UIButtonTypeCustom];
self.continueButton.translatesAutoresizingMaskIntoConstraints = NO;
[self.continueButton setTitle:@"Continue" forState:UIControlStateNormal];
self.continueButton.backgroundColor = [UIColor colorWithRed:0.0 green:122.0 / 255.0 blue:1.0 alpha:1.0];
[self.continueButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
self.continueButton.titleLabel.font = [UIFont systemFontOfSize:17.0 weight:UIFontWeightSemibold];
self.continueButton.layer.cornerRadius = 8.0;
[self.continueButton addTarget:self action:@selector(continueButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:self.continueButton];
[self.continueButton.leadingAnchor constraintEqualToAnchor:self.view.readableContentGuide.leadingAnchor constant:4.0].active = YES;
[self.continueButton.trailingAnchor constraintEqualToAnchor:self.view.readableContentGuide.trailingAnchor constant:-4.0].active = YES;
[self.continueButton.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor constant:-44.0].active = YES;
self.continueHeightConstraint = [self.continueButton.heightAnchor constraintEqualToConstant:50.0];
self.continueHeightConstraint.active = YES;
self.scrollView = [[UIScrollView alloc] init];
self.scrollView.translatesAutoresizingMaskIntoConstraints = NO;
self.scrollView.preservesSuperviewLayoutMargins = YES;
[self.view addSubview:self.scrollView];
[self.scrollView.topAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.topAnchor].active = YES;
[self.scrollView.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor].active = YES;
[self.scrollView.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor].active = YES;
self.scrollViewBottomConstraint = [self.scrollView.bottomAnchor constraintEqualToAnchor:self.continueButton.topAnchor constant:-10.0];
self.scrollViewBottomConstraint.active = YES;
self.scrollViewContentView = [[UIView alloc] init];
self.scrollViewContentView.translatesAutoresizingMaskIntoConstraints = NO;
self.scrollViewContentView.preservesSuperviewLayoutMargins = YES;
[self.scrollView addSubview:self.scrollViewContentView];
[self.scrollViewContentView.leadingAnchor constraintEqualToAnchor:self.scrollView.leadingAnchor].active = YES;
[self.scrollViewContentView.trailingAnchor constraintEqualToAnchor:self.scrollView.trailingAnchor].active = YES;
[self.scrollViewContentView.topAnchor constraintEqualToAnchor:self.scrollView.topAnchor].active = YES;
[self.scrollViewContentView.bottomAnchor constraintEqualToAnchor:self.scrollView.bottomAnchor].active = YES;
[self.scrollViewContentView.widthAnchor constraintEqualToAnchor:self.scrollView.widthAnchor].active = YES;
self.titleLabel = [[UILabel alloc] init];
self.titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
self.titleLabel.textAlignment = NSTextAlignmentCenter;
self.titleLabel.text = @"";
self.titleLabel.numberOfLines = 0;
self.titleLabel.font = [UIFont systemFontOfSize:34.0 weight:UIFontWeightBold];
[self.scrollViewContentView addSubview:self.titleLabel];
[self.titleLabel.topAnchor constraintEqualToAnchor:self.scrollViewContentView.topAnchor constant:12.0].active = YES;
[self.titleLabel.leadingAnchor constraintEqualToAnchor:self.scrollViewContentView.readableContentGuide.leadingAnchor constant:4.0].active = YES;
[self.titleLabel.trailingAnchor constraintEqualToAnchor:self.scrollViewContentView.readableContentGuide.trailingAnchor constant:-4.0].active = YES;
self.descriptionLabel = [[UILabel alloc] init];
self.descriptionLabel.translatesAutoresizingMaskIntoConstraints = NO;
self.descriptionLabel.textAlignment = NSTextAlignmentCenter;
self.descriptionLabel.text = @"";
self.descriptionLabel.numberOfLines = 0;
self.descriptionLabel.font = [UIFont systemFontOfSize:17.0 weight:UIFontWeightRegular];
[self.scrollViewContentView addSubview:self.descriptionLabel];
[self.descriptionLabel.leadingAnchor constraintEqualToAnchor:self.titleLabel.leadingAnchor].active = YES;
[self.descriptionLabel.trailingAnchor constraintEqualToAnchor:self.titleLabel.trailingAnchor].active = YES;
[self.descriptionLabel.topAnchor constraintEqualToAnchor:self.titleLabel.bottomAnchor constant:8.0].active = YES;
self.contentView = [[UIView alloc] init];
self.contentView.translatesAutoresizingMaskIntoConstraints = NO;
self.contentView.preservesSuperviewLayoutMargins = YES;
[self.scrollViewContentView addSubview:self.contentView];
[self.contentView.leadingAnchor constraintEqualToAnchor:self.scrollViewContentView.leadingAnchor].active = YES;
[self.contentView.trailingAnchor constraintEqualToAnchor:self.scrollViewContentView.trailingAnchor].active = YES;
[self.contentView.topAnchor constraintEqualToAnchor:self.descriptionLabel.bottomAnchor].active = YES;
[self.contentView.bottomAnchor constraintEqualToAnchor:self.scrollViewContentView.bottomAnchor].active = YES;
//self.scrollViewContentView.backgroundColor = [UIColor lightGrayColor];
}
-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.shadowImage = [[UIImage alloc] init];
self.navigationController.navigationBar.translucent = NO;
self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];
}
-(void)continueButtonTapped:(UIButton *)sender {
}
-(void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
self.continueHeightConstraint.constant = self.hideContinueButton ? 0.0 : 50.0;
self.scrollViewBottomConstraint.constant = self.hideContinueButton ? 0.0 : -10.0;
}
/*
#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