基本上每個app都有引導頁,雖然現(xiàn)在這種demo已經比比皆是庞钢,但感覺都不全拔恰,所以自己整理了一個因谎,只需要傳入圖片,就可以正常加載出來颜懊。由于UIPageControl的小圓點大小和顏色經常與UI設計的不相符财岔,所以后面也會提到重寫類方法,進行修改河爹。
先看下效果(圖片是在網(wǎng)上隨便找的)
Untitled.gif
把指導頁圖片傳入guideImages中
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSArray* guideImages = @[@"welcomePage_1",@"welcomePage_2",@"welcomePage_3"];
AppInstructionView* guide = [[AppInstructionView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
guide.guideImages = guideImages;
[guide rewritePageControl];
[self.window.rootViewController.view addSubview:guide];
return YES;
}
如果小圓點不符合需求則在下面修改
currentColor傳入當前圓點的顏色匠璧,nextColor傳入其他的顏色,size表示大小
#pragma mark - 重寫pageControl方法
-(void)rewritePageControl{
_pc = [[CHPageControl alloc]initWithFrame:CGRectMake(_pageSize.width * 0.5, _pageSize.height - 50, 0,0) currentColor:COLOR(72.0, 160.0, 220.0, 1) nextColor:COLOR(99.0, 99.0, 99.0, 1) size:8];
[_pc setBackgroundColor:[UIColor clearColor]];
_pc.userInteractionEnabled=NO;
[_pc setCurrentPage:0];
[_pc setNumberOfPages:_guideImages.count];
[self addSubview:_pc];
}
具體代碼GitHub地址