滚动视图自定义

xiaoxiao2021-02-28  54

首先需要导入自封装的三方《ImageScrollView》

#import "ViewController.h"

#import "ImageScrollView.h"

#import "AppDelegate.h"

#import "RootViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {

    [super viewDidLoad];

    NSArray *imgNameArr = @[@"guidePage1",@"guidePage2",@"guidePage3"];

    CGRect confirmBtnFrame = CGRectMake(self.view.frame.size.width - 200, 80, 150, 40);

    ImageScrollView *guide = [[ImageScrollView alloc]initWithFrame:self.view.frame style:ImageScrollType_Guide images:imgNameArr confirmBtnTitle:@"立即体验" confirmBtnTitleColor:[UIColor blueColor] confirmBtnFrame:confirmBtnFrame autoScrollTimeInterval:0 delegate:self];

    //添加滚动式图

    [self.view addSubview:guide];

    //添加分页控件

    [guide addPageControlToSuperView:self.view];

}

-(void)experienceDidHandle{

    RootViewController *rootVC = [[RootViewController alloc] init];

    AppDelegate *app = (AppDelegate *)[UIApplication sharedApplication].delegate;

    app.window.rootViewController = rootVC;

}

- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}

@end

无线轮播

#import "RootViewController.h"

#import "ImageScrollView.h"

@interface RootViewController ()

@end

@implementation RootViewController

- (void)viewDidLoad {

    [super viewDidLoad];

    NSArray *arr = @[@"man1.jpg",@"man2.jpg",@"man3.jpg",@"man4.jpg"];

    ImageScrollView *banner = [[ImageScrollView alloc] initWithFrame:CGRectMake(0, 100, self.view.frame.size.width, 350) style:ImageScrollType_Banner images:arr confirmBtnTitle:nil confirmBtnTitleColor:nil confirmBtnFrame:CGRectZero autoScrollTimeInterval:3 delegate:self];

    [self.view addSubview:banner];

}

-(void)bannerImageDidHandleWithIndex:(NSInteger)index{

    NSLog(@"点击了第%ld张图",index+1);

}

转载请注明原文地址: https://www.6miu.com/read-2621851.html

最新回复(0)