应用引导页配置相关 - iOS
应用引导页配置相关,通过 ScrollView 滑动至末页点击进入主页,具体实现方式如下,可供参考;
/**
加载引导页
*/
- (void)loadGuidePage {
// 基础配置
self.window = [[UIWindow alloc] initWithFrame:SCREEN_RECT];
self.window.backgroundColor = [UIColor whiteColor];
viewController = [[UIViewController alloc] init];
viewController.view.frame = self.window.bounds;
viewController.view.backgroundColor = [UIColor whiteColor]; // [UIColor generateDynamicColor:[UIColor whiteColor] darkColor:[UIColor blackColor]];
self.window.rootViewController = viewController;
[self.window makeKeyAndVisible];
// 数据源
NSArray *arrGuidePage = @[@"guidePageFirst", @"guidePageSecond", @"guidePageThird"]; // , @"guidePageFourth"
// 组件初始化
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:viewController.view.bounds];
scrollView.backgroundColor = [UIColor lightGrayColor];
scrollView.delegate = self;
scrollView.contentSize = CGSizeMake(arrGuidePage.count * SCREEN_WIDTH, self.window.frame.size.height);
scrollView.pagingEnabled = YES;
scrollView.showsHorizontalScrollIndicator = NO;
scrollView.showsVerticalScrollIndicator = NO;
[viewController.view addSubview:scrollView];
// 组件设置
for (NSInteger i = 0; i < arrGuidePage.count; i++) {
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(i * SCREEN_WIDTH, 0, SCREEN_WIDTH, SCREENH_HEIGHT)]; // self.window.frame.size.height
imageView.userInteractionEnabled = YES;
imageView.image = [[UIImage imageNamed:[NSString stringWithFormat:@"%@", arrGuidePage[i]]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
[scrollView addSubview:imageView];
if (i == arrGuidePage.count - 1) {
UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
btn.frame = CGRectMake(i * SCREEN_WIDTH + 30, SCREEN_HEIGHT - 120, SCREEN_WIDTH - 30 * 2, 50);
btn.backgroundColor = [UIColor colorWithHexString:@"#ff685e"];
[btn setTitle:@"立即体验" forState:UIControlStateNormal];
[btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
btn.layer.cornerRadius = 4.f;
btn.layer.masksToBounds = YES;
btn.layer.borderWidth = 1;
btn.layer.borderColor = [UIColor colorWithHexString:@"#ff685e"].CGColor;
btn.alpha = 0;
[UIView animateWithDuration:3.f animations:^{
btn.alpha = 1;
}];
[btn addTarget:self action:@selector(pushHomePage) forControlEvents:UIControlEventTouchUpInside];
[scrollView addSubview:btn];
}
}
}
- (void)pushHomePage {
}
以上便是此次分享的全部内容,希望能对大家有所帮助!
原文地址:https://blog.csdn.net/survivorsfyh/article/details/136390856
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!