基本上每個app都有引導頁,雖然現在這種demo已經比比皆是,但感覺都不全,所以自己整理了一個,只需要傳入圖片,就可以正常加載出來。由于UIPageControl的小圓點大小和顏色經常與UI設計的不相符,所以后面也會提到重寫類方法,進行修改。
先看下效果(圖片是在網上隨便找的)

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];
}
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持億速云。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。