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

Sign up
Appearance settings

Commit 5305522

Browse files
FunctionIntroManager - 改一下,准备上新
1 parent 6972f78 commit 5305522

File tree

1 file changed

+95
-61
lines changed

1 file changed

+95
-61
lines changed

‎Coding_iOS/Util/Manager/FunctionIntroManager.m‎

Lines changed: 95 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -7,69 +7,76 @@
77
//
88

99
#define kIntroPageKey @"intro_page_version"
10-
#define kIntroPageNum 2
10+
#define kIntroPageNum 4
1111

1212
#import "FunctionIntroManager.h"
1313
#import "EAIntroView.h"
1414
#import "SMPageControl.h"
1515
#import <NYXImagesKit/NYXImagesKit.h>
1616

17+
@interface FunctionIntroManager ()
18+
@property (strong, nonatomic) EAIntroView *introView;
19+
@end
1720

1821
@implementation FunctionIntroManager
1922
#pragma mark EAIntroPage
20-
2123
+ (void)showIntroPage{
22-
if (![self needToShowIntro]) {
23-
return;
24-
}
25-
NSMutableArray *pages = [NSMutableArray new];
26-
for (int index = 0; index < kIntroPageNum; index ++) {
27-
EAIntroPage *page = [self p_pageWithIndex:index];
28-
[pages addObject:page];
29-
}
30-
if (pages.count <= 0) {
31-
return;
32-
}
33-
EAIntroView *introView = [[EAIntroView alloc] initWithFrame:kScreen_Bounds andPages:pages];
34-
introView.backgroundColor = [UIColor whiteColor];
35-
introView.swipeToExit = YES;
36-
introView.scrollView.bounces = YES;
37-
38-
// introView.skipButton = [self p_skipButton];
39-
// introView.skipButtonY = 20.f + CGRectGetHeight(introView.skipButton.frame);
40-
// introView.skipButtonAlignment = EAViewAlignmentCenter;
41-
42-
if (pages.count <= 1) {
43-
introView.pageControl.hidden = YES;
44-
}else{
45-
introView.pageControl = [self p_pageControl];
46-
introView.pageControlY = 10.f + CGRectGetHeight(introView.pageControl.frame);
24+
if ([self needToShowIntro]) {
25+
FunctionIntroManager *manager = [FunctionIntroManager shareManager];
26+
[manager.introView showFullscreen];
27+
[self markHasBeenShowed];
4728
}
48-
[introView showFullscreen];
49-
//
50-
[self markHasBeenShowed];
5129
}
5230

5331
+ (BOOL)needToShowIntro{
54-
// return YES;
55-
5632
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
5733
NSString *preVersion = [defaults stringForKey:kIntroPageKey];
58-
BOOL needToShow = ![preVersion isEqualToString:kVersion_Coding];
59-
if (![NSDate isDuringMidAutumn]) {//中秋节期间才显示
60-
needToShow = NO;
61-
}
34+
BOOL needToShow = ![preVersion isEqualToString:kVersionBuild_Coding];
6235
return needToShow;
6336
}
6437

6538
+ (void)markHasBeenShowed{
6639
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
67-
[defaults setValue:kVersion_Coding forKey:kIntroPageKey];
40+
[defaults setValue:kVersionBuild_Coding forKey:kIntroPageKey];
6841
[defaults synchronize];
6942
}
7043

7144
#pragma mark private M
72-
+ (UIPageControl *)p_pageControl{
45+
46+
+ (instancetype)shareManager{
47+
static FunctionIntroManager *shared_manager = nil;
48+
static dispatch_once_t pred;
49+
dispatch_once(&pred, ^{
50+
shared_manager = [self new];
51+
});
52+
return shared_manager;
53+
}
54+
55+
- (instancetype)init
56+
{
57+
self = [super init];
58+
if (self) {
59+
NSMutableArray *pages = [NSMutableArray new];
60+
for (int index = 0; index < kIntroPageNum; index ++) {
61+
EAIntroPage *page = [self p_pageWithIndex:index];
62+
[pages addObject:page];
63+
}
64+
_introView = [[EAIntroView alloc] initWithFrame:kScreen_Bounds andPages:pages];
65+
_introView.backgroundColor = [UIColor whiteColor];
66+
_introView.swipeToExit = YES;
67+
_introView.scrollView.bounces = YES;
68+
_introView.skipButton = nil;
69+
if (pages.count <= 1) {
70+
_introView.pageControl.hidden = YES;
71+
}else{
72+
_introView.pageControl = [self p_pageControl];
73+
_introView.pageControlY = 10.f + CGRectGetHeight(_introView.pageControl.frame);
74+
}
75+
}
76+
return self;
77+
}
78+
79+
- (UIPageControl *)p_pageControl{
7380
UIImage *pageIndicatorImage = [UIImage imageNamed:@"intro_dot_unselected"];
7481
UIImage *currentPageIndicatorImage = [UIImage imageNamed:@"intro_dot_selected"];
7582

@@ -87,36 +94,63 @@ + (UIPageControl *)p_pageControl{
8794
return (UIPageControl *)pageControl;
8895
}
8996

90-
+ (UIButton *)p_skipButton{
91-
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width*0.7, 60)];
92-
button.titleLabel.font = [UIFont boldSystemFontOfSize:18];
97+
- (UIButton *)p_skipButton{
98+
UIButton *button = [UIButton new];
99+
[button addTarget:self action:@selector(dismissIntroView) forControlEvents:UIControlEventTouchUpInside];
100+
button.titleLabel.font = [UIFont boldSystemFontOfSize:14];
101+
button.backgroundColor = kColorNavBG;
102+
[button setTitleColor:kColor999 forState:UIControlStateNormal];
103+
[button setTitleColor:kColorDDD forState:UIControlStateHighlighted];
104+
[button setTitle:@"跳过" forState:UIControlStateNormal];
105+
[button doBorderWidth:0 color:nil cornerRadius:15.0];
106+
return button;
107+
}
108+
109+
- (UIButton *)p_useImmediatelyButton{
110+
UIButton *button = [UIButton new];
111+
[button addTarget:self action:@selector(dismissIntroView) forControlEvents:UIControlEventTouchUpInside];
112+
button.titleLabel.font = [UIFont boldSystemFontOfSize:20];
113+
button.backgroundColor = kColorBrandGreen;
114+
[button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
115+
[button setTitleColor:[UIColor lightTextColor] forState:UIControlStateHighlighted];
93116
[button setTitle:@"立即体验" forState:UIControlStateNormal];
94-
[button setTitleColor:kColorBrandGreen forState:UIControlStateNormal];
95-
[button setTitleColor:[UIColor colorWithHexString:@"0x1b9d59"] forState:UIControlStateHighlighted];
117+
[button doBorderWidth:0 color:nil cornerRadius:4.0];
96118
return button;
97119
}
98120

99-
+ (EAIntroPage *)p_pageWithIndex:(NSInteger)index{
121+
- (void)dismissIntroView{
122+
[self.introView hideWithFadeOutDuration:0.3];
123+
}
124+
125+
- (EAIntroPage *)p_pageWithIndex:(NSInteger)index{
100126
NSString *imageName = [NSString stringWithFormat:@"intro_page%ld", (long)index];
101-
if (kDevice_Is_iPhone6Plus) {
102-
imageName = [imageName stringByAppendingString:@"_ip6+"];
103-
}else if (kDevice_Is_iPhone6){
104-
imageName = [imageName stringByAppendingString:@"_ip6"];
105-
}else if (kDevice_Is_iPhone5){
106-
imageName = [imageName stringByAppendingString:@"_ip5"];
107-
}else{
108-
imageName = [imageName stringByAppendingString:@"_ip4"];
109-
}
110-
UIImage *image = [UIImage imageNamed:imageName];
111-
UIImageView *imageView;
112-
if (!image) {
113-
imageView = [UIImageView new];
114-
imageView.backgroundColor = [UIColor randomColor];
115-
}else{
116-
imageView = [[UIImageView alloc] initWithImage:image];
117-
}
127+
imageName = [imageName stringByAppendingString:(kDevice_Is_iPhone6Plus? @"_ip6+":
128+
kDevice_Is_iPhone6? @"_ip6":
129+
kDevice_Is_iPhone5? @"_ip5":
130+
@"_ip4")];
131+
UIImageView *imageView = [UIImageView new];
132+
imageView.userInteractionEnabled = YES;
118133
imageView.contentMode = UIViewContentModeScaleAspectFill;
119134
imageView.clipsToBounds = YES;
135+
imageView.image = [UIImage imageNamed:imageName];
136+
imageView.backgroundColor = imageView.image? [UIColor clearColor]: [UIColor randomColor];
137+
if (index < kIntroPageNum - 1) {
138+
UIButton *button = [self p_skipButton];
139+
[imageView addSubview:button];
140+
[button mas_makeConstraints:^(MASConstraintMaker *make) {
141+
make.size.mas_equalTo(CGSizeMake(60, 30));
142+
make.top.equalTo(imageView).offset(30);
143+
make.right.equalTo(imageView).offset(-20);
144+
}];
145+
}else{
146+
UIButton *button = [self p_useImmediatelyButton];
147+
[imageView addSubview:button];
148+
[button mas_makeConstraints:^(MASConstraintMaker *make) {
149+
make.size.mas_equalTo(CGSizeMake(200, 44));
150+
make.centerX.equalTo(imageView);
151+
make.bottom.equalTo(imageView).offset(-70);
152+
}];
153+
}
120154
EAIntroPage *page = [EAIntroPage pageWithCustomView:imageView];
121155
return page;
122156
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /