Welcome you to join iOS Dynamic effect special attack team — >QQ group: 547897182 iOS Dynamic effect special attack team — > Bear: 648070256 CRAnimation open source project: github.com/CRAnimation…

Making:CRNumberFadedAnimation

Off and on for 3 weeks, the dynamic effect was restored.

The prototype looks like this.





048D2384C794BDF62E9D8145002217B0.gif

The end result is this





CRNumberFaded2.gif

Of course, some of the controls in this dynamic effect can still be used. Everyone’s English is very good, unless it is particularly difficult to understand, I will not write notes in general.

Number Switch control CRNumberFaded

The CRNumberFaded control actually has only three labels being reused all the time. So you don’t have to worry about memory.

// Basic usage
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];

// Parameters and methods can be used
@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;    // Whether to allow infinite scrolling

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

// Supported proxy methods
@protocol CRNumberFadedDelegate <NSObject>

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

@endCopy the code

The slider control CRSlider

CRSlider inherited from UIControl, supporting the UIControlEventValueChanged to monitor events. The native UISlider’s customizable properties did not meet this dynamic requirement and had to be rewritten.

// Basic usage
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];

// Parameters and methods can be used
@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;

// Supported proxy methods
@protocol CRSliderDelegate <NSObject>
- (void)thumbImageVDidSlided:(CRSlider *)slider;
@endCopy the code

Slide bar indicator control CRSliderIndicator

The circular groove in the indicator took some time to create. The problem of adaptation is mainly considered. Think about how to do it with proportion. Sketch the curve, then pick out several control points of Bezier curve, and make adaptation with proportion. The diagram below shows only a few dots on the left side, and the same on the right side.





CRSliderIndicatorMind.png

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

// Parameters and methods can be used
@property (assign.nonatomic) CGFloat   circleCenterX;              // CenterX for Slider button
@property (assign.nonatomic) CGFloat   r;                          // Radius of Slider button
@property (assign.nonatomic) CGFloat   toCircleCenterYDistance;    // The vertical distance of the Slider
@property (strong.nonatomic) NSArray   *gradientColors;            // Background gradient array
@property (assign.nonatomic) CGFloat   chipOffX;

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

Lifting effect is worried about the details of the continuous debugging, because you want to restore as much as possible or need to be slowly polished. But I hope you enjoy it and can actually use it in the project. If you encounter problems or bugs in the process of using it, welcome to issue on Github.