iOS 自动竖直滚动Banner 类似淘宝头条

2018-12-13  本文已影响0人  pokeey

Demo地址

类似于淘宝头条的自动竖直滚动的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];
    }];
}

如果您有更好的想法,请不吝赐教!

上一篇下一篇

猜你喜欢

热点阅读