Code Monkey home page Code Monkey logo

crnumberfadedanimation's Introduction

欢迎同样喜爱动效的你加入
iOS动效特攻队–>QQ群:547897182
iOS动效特攻队–>熊熊:648070256
CRAnimation开源项目:https://github.com/CRAnimation/CRAnimation

断断续续3周的时间,把这个动效还原出来了。

原型是这样的。

CRNumberFadedOrigin.gif

最终的实现效果是这样的

CRNumberFaded.gif

当然了,这个动效里面的部分控件还是可以使用的。大家英文都辣么好,除非特别难理解的,一般的我就不写注释了。

数字切换控件 CRNumberFaded

CRNumberFaded 控件实际上只有三个Label 在一直复用。所以可以不用担心内存的问题哦。

//基本用法
CRNumberFaded *_numberFadedView = [[CRNumberFaded alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
_numberFadedView.font = [UIFont fontWithName:@"Helvetica-Bold" size:150];
_numberFadedView.textColor = [UIColor whiteColor];
_numberFadedView.strings = strings;
_numberFadedView.delegate = self;
_numberFadedView.backgroundColor = [UIColor clearColor];
[_sliderIndicator addSubview:_numberFadedView];

//可使用参数和方法
@property (weak, nonatomic) id <CRNumberFadedDelegate> delegate;
@property (strong, nonatomic) NSArray   *strings;
@property (strong, nonatomic) UIFont    *font;
@property (strong, nonatomic) UIColor   *textColor;
@property (assign, nonatomic) BOOL      allowCircle;    //是否允许无限滚动

- (void)showNextView;
- (void)showLastView;
- (void)showToIndex:(int)toIndex;

//支持的代理方法
@protocol CRNumberFadedDelegate <NSObject>

- (void)willShowLastOneFadeAnimationWithString:(NSString *)string index:(int)index;
- (void)willStartFirstAnimationWithString:(NSString *)string index:(int)index;
- (void)fadingAnimationWithString:(NSString *)string index:(int)index;

@end

滑杆控件 CRSlider

CRSlider 继承自UIControl ,支持UIControlEventValueChanged 监听事件。 原生的UISlider可自定义的属性满足不了这个动效的需求,只能自己重新写了。

//基本用法
CRSlider *_slider = [[CRSlider alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 40)];
_slider.delegate = self;
_slider.minimumValue = 0;
_slider.maximumValue = _maxNum;
_slider.poleImageVOffX = _poleImageVOffX;
[_slider addTarget:self action:@selector(testSliderChanged:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:_slider];

//可使用参数和方法
@property(nonatomic) float value;
@property(nonatomic) float minimumValue;
@property(nonatomic) float maximumValue;

@property(nonatomic) float poleImageVOffX;
@property (strong, nonatomic) UIImageView *poleImageV;
@property (strong, nonatomic) UIImageView *thumbImageV;

//支持的代理方法
@protocol CRSliderDelegate <NSObject>
- (void)thumbImageVDidSlided:(CRSlider *)slider;
@end

滑杆指示器控件 CRSliderIndicator

指示器里面的这个圆槽是折腾了一段时间才出来的。主要考虑到适配的问题,想想还是用比例来做的,通过Sketch临摹出曲线,然后把贝塞尔曲线的几个控制点挑出来,通过比例来做适配。图示如下,只点出来了左半边的几个点,右半边的同理。

CRSliderIndicatorMind.png

//基本用法
CRSliderIndicator *_sliderIndicator = [[CRSliderIndicator alloc] initWithFrame:CGRectMake(0, _customNaviBarView.maxY, WIDTH, sliderIndicatorHeight) withStrings:strings];
_sliderIndicator.chipOffX = _poleImageVOffX;
[self.view addSubview:_sliderIndicator];

//可使用参数和方法
@property (assign, nonatomic) CGFloat   circleCenterX;              //Slider按钮的CenterX
@property (assign, nonatomic) CGFloat   r;                          //Slider按钮的半径
@property (assign, nonatomic) CGFloat   toCircleCenterYDistance;    //Slider按钮的垂直距离
@property (strong, nonatomic) NSArray   *gradientColors;            //背景渐变色数组
@property (assign, nonatomic) CGFloat   chipOffX;

- (instancetype)initWithFrame:(CGRect)frame withStrings:(NSArray *)strings;

撸动效揪心的还是细节的不断调试,因为想尽可能的还原出来还是需要慢慢打磨的。不过希望大家能喜欢,也能真正的用在项目中。 如果各位在使用过程中遇到问题或者bug,欢迎在github上提出issue。

crnumberfadedanimation's People

Contributors

bearran avatar

Watchers

James Cloos avatar PaulPan avatar

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.