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

Latest commit

 

History

History
History
124 lines (108 loc) · 4.22 KB

File metadata and controls

124 lines (108 loc) · 4.22 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
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
//
// 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 2
#import "FunctionIntroManager.h"
#import "EAIntroView.h"
#import "SMPageControl.h"
#import <NYXImagesKit/NYXImagesKit.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.backgroundColor = [UIColor whiteColor];
introView.swipeToExit = YES;
introView.scrollView.bounces = YES;
// 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 = 10.f + CGRectGetHeight(introView.pageControl.frame);
}
[introView showFullscreen];
//
[self markHasBeenShowed];
}
+ (BOOL)needToShowIntro{
// return YES;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *preVersion = [defaults stringForKey:kIntroPageKey];
BOOL needToShow = ![preVersion isEqualToString:kVersion_Coding];
if (![NSDate isDuringMidAutumn]) {//中秋节期间才显示
needToShow = NO;
}
return needToShow;
}
+ (void)markHasBeenShowed{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setValue:kVersion_Coding forKey:kIntroPageKey];
[defaults synchronize];
}
#pragma mark private M
+ (UIPageControl *)p_pageControl{
UIImage *pageIndicatorImage = [UIImage imageNamed:@"intro_dot_unselected"];
UIImage *currentPageIndicatorImage = [UIImage imageNamed:@"intro_dot_selected"];
if (!kDevice_Is_iPhone6 && !kDevice_Is_iPhone6Plus) {
CGFloat desginWidth = 375.0;//iPhone6 的设计尺寸
CGFloat scaleFactor = kScreen_Width/desginWidth;
pageIndicatorImage = [pageIndicatorImage scaleByFactor:scaleFactor];
currentPageIndicatorImage = [currentPageIndicatorImage scaleByFactor:scaleFactor];
}
SMPageControl *pageControl = [SMPageControl new];
pageControl.pageIndicatorImage = pageIndicatorImage;
pageControl.currentPageIndicatorImage = currentPageIndicatorImage;
[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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.