forked from coding/Coding-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunctionIntroManager.m
More file actions
108 lines (95 loc) · 3.54 KB
/
Copy pathFunctionIntroManager.m
File metadata and controls
108 lines (95 loc) · 3.54 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
//
// FunctionIntroManager.m
// Coding_iOS
//
// Created by Ease on 15/8/6.
// Copyright (c) 2015年 Coding. All rights reserved.
//
#define kIntroPageKey @"intro_page_version"
#define kIntroPageNum 1
#import "FunctionIntroManager.h"
#import "EAIntroView.h"
#import "SMPageControl.h"
@implementation FunctionIntroManager
#pragma mark EAIntroPage
+ (void)showIntroPage{
if (![self needToShowIntro]) {
return;
}
NSMutableArray *pages = [NSMutableArray new];
for (int index = 0; index < kIntroPageNum; index ++) {
EAIntroPage *page = [self p_pageWithIndex:index];
[pages addObject:page];
}
if (pages.count <= 0) {
return;
}
EAIntroView *introView = [[EAIntroView alloc] initWithFrame:kScreen_Bounds andPages:pages];
introView.swipeToExit = NO;
introView.scrollView.bounces = NO;
introView.skipButton = [self p_skipButton];
introView.skipButtonY = 20.f + CGRectGetHeight(introView.skipButton.frame);
introView.skipButtonAlignment = EAViewAlignmentCenter;
if (pages.count <= 1) {
introView.pageControl.hidden = YES;
}else{
introView.pageControl = [self p_pageControl];
introView.pageControlY = 130;
}
[introView showFullscreen];
//
[self markHasBeenShowed];
}
+ (BOOL)needToShowIntro{
return NO;//这个版本不需要
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *preVersion = [defaults stringForKey:kIntroPageKey];
BOOL needToShow = ![preVersion isEqualToString:kVersion_Coding];
return needToShow;
}
+ (void)markHasBeenShowed{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setValue:kVersion_Coding forKey:kIntroPageKey];
[defaults synchronize];
}
#pragma mark private M
+ (UIPageControl *)p_pageControl{
SMPageControl *pageControl = [SMPageControl new];
pageControl.pageIndicatorImage = [UIImage imageNamed:@"banner__page_unselected"];
pageControl.currentPageIndicatorImage = [UIImage imageNamed:@"banner__page_selected"];
[pageControl sizeToFit];
return (UIPageControl *)pageControl;
}
+ (UIButton *)p_skipButton{
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width*0.7, 60)];
button.titleLabel.font = [UIFont boldSystemFontOfSize:18];
[button setTitle:@"立即体验" forState:UIControlStateNormal];
[button setTitleColor:[UIColor colorWithHexString:@"0x3bbd79"] forState:UIControlStateNormal];
[button setTitleColor:[UIColor colorWithHexString:@"0x1b9d59"] forState:UIControlStateHighlighted];
return button;
}
+ (EAIntroPage *)p_pageWithIndex:(NSInteger)index{
NSString *imageName = [NSString stringWithFormat:@"intro_page%ld", (long)index];
if (kDevice_Is_iPhone6Plus) {
imageName = [imageName stringByAppendingString:@"_ip6+"];
}else if (kDevice_Is_iPhone6){
imageName = [imageName stringByAppendingString:@"_ip6"];
}else if (kDevice_Is_iPhone5){
imageName = [imageName stringByAppendingString:@"_ip5"];
}else{
imageName = [imageName stringByAppendingString:@"_ip4"];
}
UIImage *image = [UIImage imageNamed:imageName];
UIImageView *imageView;
if (!image) {
imageView = [UIImageView new];
imageView.backgroundColor = [UIColor randomColor];
}else{
imageView = [[UIImageView alloc] initWithImage:image];
}
imageView.contentMode = UIViewContentModeScaleAspectFill;
imageView.clipsToBounds = YES;
EAIntroPage *page = [EAIntroPage pageWithCustomView:imageView];
return page;
}
@end