欢迎同样喜爱动效的你加入
iOS动效特攻队–>QQ群:547897182
iOS动效特攻队–>熊熊:648070256
CRAnimation开源项目:https://github.com/CRAnimation/CRAnimation
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滑杆控件 CRSliderCRSlider 继承自UIControl ,支持UIControlEventValueChanged 监听事件。
原生的UISlider可自定义的属性满足不了这个动效的需求,只能自己重新写了。
指示器里面的这个圆槽是折腾了一段时间才出来的。主要考虑到适配的问题,论文,想想还是用比例来做的,通过Sketch临摹出曲线,然后把贝塞尔曲线的几个控制点挑出来,开题报告,通过比例来做适配。图示如下,只点出来了左半边的几个点,右半边的同理。
//基本用法 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。