应用引导页配置相关 - iOS

本文介绍了在iOS项目中配置应用引导页的方法,包括使用UIScrollView、UIImageView展示多页内容,以及设置按钮实现从最后一页滑动到主页的功能。
摘要由CSDN通过智能技术生成

应用引导页配置相关,通过 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 {

}

以上便是此次分享的全部内容,希望能对大家有所帮助!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值