iOS引导页

GuideViewController.h

#import <UIKit/UIKit.h>


@interface GuideViewController : UIViewController<UIScrollViewDelegate>

@property (nonatomic) UIScrollView *scrollView;

@property (nonatomic) NSArray *array;//保存图片名


@end


GuideViewController.m

#import "GuideViewController.h"


#define HEIGHT [UIScreen mainScreen].bounds.size.height

#define WIDTH [UIScreen mainScreen].bounds.size.width


@interface GuideViewController ()


@end


@implementation GuideViewController


- (void)viewDidLoad {

    [super viewDidLoad];

    _scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];

    _scrollView.backgroundColor = [UIColor groupTableViewBackgroundColor];

    [self.view addSubview: _scrollView];

    

    //修复ScrollerView偏移(下移)

    self.automaticallyAdjustsScrollViewInsets = NO;

    

    //设置是否有橡皮筋效果属性

    self.scrollView.bounces = YES;

    //设置是否使用分页属性

    _scrollView.pagingEnabled = YES;

    //设置是否允许滚动属性

    _scrollView.scrollEnabled = YES;

    //设置是否显示水平、竖直滚动条属性

    _scrollView.showsHorizontalScrollIndicator = YES;

    _scrollView.showsVerticalScrollIndicator = YES;

    _scrollView.userInteractionEnabled = YES;

    

    if (HEIGHT == 480) {

        _array = [NSArray arrayWithObjects:[UIImage imageNamed:@"引导页1-640-960.png.png"],[UIImage imageNamed:@"引导页2-640-960.png.png"],[UIImage imageNamed:@"引导页3-640-960.png.png"], nil];

    } else if (HEIGHT == 568){

        _array = [NSArray arrayWithObjects:[UIImage imageNamed:@"引导页1-720-1280.png"],[UIImage imageNamed:@"引导页2-720-1280.png"],[UIImage imageNamed:@"引导页3-720-1280.png"], nil];

    }else if (HEIGHT == 667){

        _array = [NSArray arrayWithObjects:[UIImage imageNamed:@"引导页1-720-1280.png"],[UIImage imageNamed:@"引导页2-720-1280.png"],[UIImage imageNamed:@"引导页3-720-1280.png"], nil];

    }else if (HEIGHT == 736){

        _array = [NSArray arrayWithObjects:[UIImage imageNamed:@"引导页1-1080-1920.png"],[UIImage imageNamed:@"引导页2-1080-1920.png"],[UIImage imageNamed:@"引导页3-1080-1920.png"], nil];

    }



    for (int i=0; i<[_array count]; i++) {

        UIImageView *view = [[UIImageView alloc]initWithFrame:CGRectMake(i*_scrollView.frame.size.width, 0, _scrollView.frame.size.width, _scrollView.frame.size.height)];

        view.userInteractionEnabled = YES;

        if (i == _array.count-1) {

            _button = [UIButton buttonWithType:UIButtonTypeSystem];

            

            if (HEIGHT == 480) {

                _button.frame = CGRectMake((WIDTH-130)/2, 115, 130, 40);

            } else if (HEIGHT == 568){

                _button.frame = CGRectMake((WIDTH-150)/2, 137, 150, 40);

            }else if (HEIGHT == 667){

               _button.frame = CGRectMake((WIDTH-160)/2, 158, 160, 50);

            }else if (HEIGHT == 736){

                _button.frame = CGRectMake((WIDTH-200)/2, 176, 200, 60);

            }

            [_button setTitleColor:[UIColor redColor] forState:UIControlStateNormal];

            [_button setBackgroundColor:[UIColor clearColor]];

            [_button addTarget:self action:@selector(startClick:) forControlEvents:UIControlEventTouchUpInside];

            [view addSubview:_button];

        }

        view.image = _array[i];

        [_scrollView addSubview:view];

    }

    //设置内容范围属性

    _scrollView.contentSize = CGSizeMake([_array count]*self.view.frame.size.width, self.view.frame.size.height);

}


#pragma scrollViewDelegate

-(void)scrollViewDidScroll:(UIScrollView *)scrollView{

    NSLog(@"完成滚动!!");

}

-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{

    NSLog(@"将要开始拖动!!");

}

-(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{

    NSLog(@"结束拖动!!");

}

-(void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView{

    NSLog(@"滚动将要开始减速!!");

}

-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{

    NSLog(@"滚动减速到停止!!");

}

-(BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView{

    NSLog(@"是否滚动到顶部??");

    return YES;

}

-(void)scrollViewDidScrollToTop:(UIScrollView *)scrollView{

    NSLog(@"滚动到顶部!!");

}


@end




  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值