Giter Site home page Giter Site logo

kttitlerolling's Introduction

CDDTitleRolling

电商轮播标题广告(仿京东、淘宝) 项目效果图

项目结构图

实现方面,我利用UIView animateWithDuration结合CALayer的CATransform3D坐标变换做上下翻滚动画。

#pragma mark - 标题滚动

  • (void)titleRolling{

    if (self.saveMiddleArray.count > 1) { //所存的每组滚动 __weak typeof(self)weakSelf = self;

      [UIView animateWithDuration:self.rollingTime animations:^{
          
          [self getMiddleArrayWithIndex:0 WithAngle:- M_PI_2 Height:- RollingViewHeight / 2]; //第0组
          
          [self getMiddleArrayWithIndex:1 WithAngle:0 Height:0]; //第一组
          
      } completion:^(BOOL finished) {
          
          if (finished == YES) { //旋转结束
              UIButton *newMiddleView = [weakSelf getMiddleArrayWithIndex:0 WithAngle:M_PI_2 Height: -RollingViewHeight / 2];
              [weakSelf.saveMiddleArray addObject:newMiddleView];
              
              [weakSelf.saveMiddleArray removeObjectAtIndex:0];
          }
      }];
    

    }

}

#pragma mark - CATransform3D翻转

  • (UIButton *)getMiddleArrayWithIndex:(NSInteger)index WithAngle:(CGFloat)angle Height:(CGFloat)height { if (index > _saveMiddleArray.count) return 0; UIButton *middleView = self.saveMiddleArray[index];

    CATransform3D trans = CATransform3DIdentity; trans = CATransform3DMakeRotation(angle, 1, 0, 0); trans = CATransform3DTranslate(trans, 0, height, height); middleView.layer.transform = trans;

    return middleView; }

如果这个Demo让你有所收获,请Star and Fork。

注:如果遇到问题还请Issues,我会尽快回复。

kttitlerolling's People

Contributors

keenteam1990 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

ppllock

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.