Skip to content

A view that scrolls automatically in a vertical direction

License

Notifications You must be signed in to change notification settings

Luo-Kuang/ZFAutoScrollBanner

Repository files navigation

ZFAutoScrollBanner

类似于淘宝头条的自动竖直滚动的Bannnnnnnner

gif图有丢帧,其实动画是连续的

ZFAutoScrollBanner.gif

核心代码

- (void)scroll {

    self.index++;
    if (self.index == self.dataArr.count) {
        self.index = 0;
    }

    [self configBannerItemsIndex:self.index];
    
    [UIView animateWithDuration:.3 animations:^{
        [self.banner0 mas_updateConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self).offset(-30);
        }];
        [self layoutIfNeeded];
    } completion:^(BOOL finished) {
        self.flag = !self.flag;
        ZFAutoBannerItemView *temp = self.banner1;
        self.banner1 = self.banner0;
        self.banner0 = temp;
        [self makeConstraints];
    }];
}

About

A view that scrolls automatically in a vertical direction

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published