Latest 0.0.1
Homepage https://github.com/hahand/HACycleView
License MIT
Platforms ios 10.0, requires ARC
Authors

HACycleViewDemo

HACycleView is a simple component easily use and extend inherited from UIScrollView.

Examples

As a banner.

banner

As a message reporter.

system reporter

Installation

  • Download the demo, drag HACycleView folder in your project.

  • Also you can use cocoapods by adding pod 'HACycleView' to your Podfile

Usage

You can initialize a cycleView by using init or IBOutlet.

- (void)loadCycleView {    
    HACycleViewConfig *config = [HACycleViewConfig new];
    config.pageDelegate = self;

    HACycleView *cycleView =[[HACycleView alloc] initWithFrame: CGRectMake(0, 0, 100, 80)];

    [self.view addSubview: cycleView];
    [cycleView runWithConfig: config];
}

Class

HACycleViewConfig is config class.

  • verticalDirection : The scroll direction.

  • cycleScrollEnable : Whether you can cycle scroll the view.

  • autoScrollEnable : Create a timer and automic scroll.

  • autoScrollOrderDescending : Automic scroll direction.

  • autoScrollDuration : Automic scroll duration between each cell.

  • delegate : An object confirms HACycleViewDelegate protocol.

In HACycleViewDelegate protocol.

  • numberOfCellsInCycleView:: You must return the number of cells to calculate contentSize and offset.

  • cycleView:cellAtIndex: : You must return a nonnull view confirm HACycleViewCell protocol.

  • cycleView:didScrollFromIndex:toNewIndex: Will be called when scroll to each cell;

In HACycleViewCell protocol.

  • reuseIdentify: You just need to declare a reuse key to store cell and dequeue it from the reusePool.

HACycleView has a reusePool collecting cells when remove from container.

- ( UIView<HACycleViewCell> * _Nonnull )cycleView: (HACycleView *)cycleView cellAtIndex: (NSUInteger)index {
    NSString *cellId = @"MyLabel";
    MyLabel *cell = (MyLabel *)[cycleView dequeueReusableCellWithIdentifier: cellId];
    if (cell == nil) {
        cell = [[MyLabel alloc] init];
        cell.reuseIdentify = cellId;
    }
    cell.text = self.dataSource[index];
    return cell;
    //...
}

Set cycleView.clipsToBounds = NO, there’re only as much as 3 sub views in the cycleView.

system reporter

HACycleView support to scroll by calling method.

- (void)nextPictureOnPress: (UIButton *)sender {
    if (sender == self.preBtn) {
        [self.cycleView scrollToPreCell: YES];
    }
    if (sender == self.nextBtn) {
        [self.cycleView scrollToNextCell: YES];
    }
}

Requirements

HACycleView requires iOS 10.0+

License

HACycleView is released under the MIT license. See LICENSE file for details.

Latest podspec

{
    "name": "HACycleView",
    "version": "0.0.1",
    "summary": "A simple cycle view for iOS .",
    "homepage": "https://github.com/hahand/HACycleView",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "hahand": "[email protected]"
    },
    "platforms": {
        "ios": "10.0"
    },
    "source": {
        "git": "https://github.com/hahand/HACycleView.git",
        "tag": "0.0.1"
    },
    "source_files": [
        "HACycleView/**/*.{h,m}",
        "HACycleView/*.{h,m}"
    ],
    "requires_arc": true
}

Pin It on Pinterest

Share This