Commit 7491a21a cgx

今日积分添加动画(该动画用户体验需要优化)

1 个父辈 f0390d7d
正在显示 61 个修改的文件 包含 160 行增加114 行删除
//
// BeizerView.m
// DreamSleep
//
// Created by peter on 2022/7/2.
//
#import "BeizerView.h"
@interface BeizerView ()
@property(nonatomic,assign) float step;
@property(nonatomic,assign) float total;
@end
@implementation BeizerView
- (void)drawRect:(CGRect)rect
{
[[UIColor orangeColor] set];
DSLog(@"====:%f, %f", self.width, self.height);
UIBezierPath *path9 = [UIBezierPath bezierPath];
[path9 moveToPoint:CGPointMake(0, self.height)];
[path9 addLineToPoint:CGPointMake(36+36, self.height)];
[path9 addCurveToPoint:CGPointMake(self.width, 0) controlPoint1:CGPointMake(36+36, self.height) controlPoint2:CGPointMake(self.width - 56, self.height - 34)];
// [path9 addQuadCurveToPoint:CGPointMake(self.width, 0) controlPoint:CGPointMake(self.width - 56, self.height - 34)];
// [path9 stroke];
// 创建CAShapeLayer
CAShapeLayer *layer = [CAShapeLayer layer];
layer.fillColor = [UIColor clearColor].CGColor;
layer.lineWidth = 2.0f;
layer.lineCap = kCALineCapRound;
layer.lineJoin = kCALineJoinRound;
layer.strokeColor = [UIColor blueColor].CGColor;
[self.layer addSublayer:layer];
layer.path = path9.CGPath;
// CAGradientLayer *gradLayer = [CAGradientLayer layer];
// gradLayer.frame = CGRectMake(100, 100, 100, 100);
// gradLayer.colors = @[(__bridge id)[UIColor redColor].CGColor,(__bridge id)[UIColor greenColor].CGColor,(__bridge id)[UIColor orangeColor].CGColor];
// gradLayer.startPoint = CGPointMake(0, 1);
// gradLayer.endPoint = CGPointMake(1, 1);
// gradLayer.locations = @[@0.2,@0.5,@0.7];
// gradLayer.type = kCAGradientLayerAxial;
// [layer addSublayer:gradLayer];
// 创建Animation
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
animation.fromValue = @(0.0);
animation.toValue = @(1.0);
layer.autoreverses = NO;
animation.duration = 4.0;
// 设置layer的animation
[layer addAnimation:animation forKey:nil];
}
- (void)animateProgress:(float)progress animate:(BOOL)animate
{
// _progressRate = progress;
if (animate) {
self.total = progress;
/*
利用定时器做进度动画
*/
[NSTimer scheduledTimerWithTimeInterval:0.01
target:self
selector:@selector(numberAnimation:)
userInfo:nil
repeats:YES];
}else{
[self setNeedsDisplay];
}
}
-(void)numberAnimation:(NSTimer*)timer {
_step += 0.01;
if (self.step > self.total) {
[timer invalidate];
timer = nil;
self.step = 0;
return;
}
self.progressRate = self.step;
[self setNeedsDisplay];
}
@end
//
// BeizerView.m
// DreamSleep
//
// Created by peter on 2022/7/2.
//
#import "BeizerView.h"
@interface BeizerView ()
@property(nonatomic,assign) float step;
@property(nonatomic,assign) float total;
@end
@implementation BeizerView
- (void)drawRect:(CGRect)rect
{
CGFloat x = -self.width, y = -self.height, width = 2*self.width, height = 2*self.height, startAngle = -95*M_PI_2/90.0, endAngle = -15*M_PI_2/90.0;
CGContextRef context = UIGraphicsGetCurrentContext();
//设置填充颜色
CGContextSetFillColorWithColor(context, [UIColor redColor].CGColor);
//画椭圆,这里画的是个实心椭圆
//如果想画椭圆的边框,只需要把这句改为
CGContextStrokeEllipseInRect(context, CGRectMake(x, y, width, height));
// CGContextFillEllipseInRect(context, CGRectMake(x, y, width, height));
CGContextSaveGState(context);
//
// CGPoint center = CGPointMake(x + width / 2.0, y + height / 2.0);
// UIBezierPath* clip = [UIBezierPath bezierPathWithArcCenter:center
// radius:MAX(width, height)
// startAngle:startAngle
// endAngle:endAngle
// clockwise:NO];
// [clip addLineToPoint:center];
// [clip closePath];
// [clip addClip];
//
// UIBezierPath *arc = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(x, y, width, height)];
// [[UIColor blackColor] setStroke];
// [arc stroke];
CGContextRestoreGState(context);
// 绘制总弧线
// UIBezierPath *aPath1 = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(-self.width, -self.height -2, 2*self.width + 2, 2*self.height + 2)];
// aPath1.lineWidth = 2;
// aPath1.lineJoinStyle = kCGLineJoinRound;
// [UIColor.blueColor set];
// [aPath1 stroke];
// [self debugViewShowBorder];
// 渐变色
// CAGradientLayer *gradLayer = [CAGradientLayer layer];
// gradLayer.frame = aPath1.bounds;
// gradLayer.colors = @[(__bridge id)ColorFromHex(0x9CE5EF).CGColor,(__bridge id)ColorFromHex(0x217B8B).CGColor];
// gradLayer.startPoint = CGPointMake(0, .5);
// gradLayer.endPoint = CGPointMake(1, .5);
// gradLayer.locations = @[@0,@1.0];
// gradLayer.type = kCAGradientLayerRadial;
// [self.layer addSublayer:gradLayer];
// 绘制当前弧线
// UIBezierPath *aPath2=[UIBezierPath bezierPathWithOvalInRect:CGRectMake(-self.width, -self.height -2, 2*self.width + 2, 2*self.height + 2)];
// aPath2.lineWidth = 2.0;
// [aPath2 stroke];
// self.clipsToBounds = YES;
// UIBezierPath* aPath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(50, 0)
// radius:self.width
// startAngle:-75*M_PI_2/90
// endAngle:-55*M_PI_2/90
// clockwise:NO];
// aPath.lineWidth = 2.0;
// aPath.lineCapStyle = kCGLineCapRound; //线条拐角
// aPath.lineJoinStyle = kCGLineJoinRound; //终点处理
// [aPath stroke];
// self.clipsToBounds = YES;
// [self debugViewShowBorder];
// 创建CAShapeLayer
// CAShapeLayer *layer = [CAShapeLayer layer];
// layer.fillColor = [UIColor clearColor].CGColor;
// layer.lineWidth = 2.0f;
// layer.lineCap = kCALineCapRound;
// layer.lineJoin = kCALineJoinRound;
// layer.strokeColor = [UIColor blueColor].CGColor;
// [self.layer addSublayer:layer];
// layer.path = aPath.CGPath;
// 创建Animation
// CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
// animation.fromValue = @(0.0);
// animation.toValue = @(1.0);
// layer.autoreverses = NO;
// animation.duration = 4.0;
// 设置layer的animation
// [layer addAnimation:animation forKey:nil];
}
- (void)animateProgress:(float)progress animate:(BOOL)animate
{
// _progressRate = progress;
if (animate) {
self.total = progress;
/*
利用定时器做进度动画
*/
[NSTimer scheduledTimerWithTimeInterval:0.01
target:self
selector:@selector(numberAnimation:)
userInfo:nil
repeats:YES];
}else{
[self setNeedsDisplay];
}
}
-(void)numberAnimation:(NSTimer*)timer {
_step += 0.01;
if (self.step > self.total) {
[timer invalidate];
timer = nil;
self.step = 0;
return;
}
self.progressRate = self.step;
[self setNeedsDisplay];
}
@end
......@@ -6,10 +6,11 @@
//
#import "DailyBgView.h"
#import "DPScrollNumberLabel.h"
@interface DailyBgView ()
@property (nonatomic, strong) UIImageView *bgIV;
@property (nonatomic, strong) UILabel *pointsLab;
@property (nonatomic, strong) DPScrollNumberLabel *pointsLab;
@property (nonatomic, strong) UILabel *todayLab;
@end
......@@ -25,19 +26,18 @@
}
- (void)updateTodayPointData:(int)points {
self.pointsLab.text = [NSString stringWithFormat:@"%d", points];
// 积分需要动画显示效果
[self.pointsLab changeToNumber:@(points) animated:YES];
self.todayLab.text = @"今日积分";
[self.pointsLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self).offset(15);
make.top.equalTo(self).offset(136);
make.size.mas_equalTo(CGSizeMake(self.pointsLab.frame.size.width, self.pointsLab.frame.size.height));
}];
[self.todayLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.pointsLab.mas_right).offset(2);
make.bottom.equalTo(self.pointsLab).offset(-9);
}];
// 积分需要动画显示效果
}
#pragma mark - lazy
......@@ -49,10 +49,10 @@
return _bgIV;
}
- (UILabel *)pointsLab {
- (DPScrollNumberLabel *)pointsLab {
if (!_pointsLab) {
_pointsLab = [UILabel labWithFont:BoldFont(46.0)];
_pointsLab.dk_textColorPicker = DKColorPickerWithKey(Dk_TITLE);
_pointsLab = [[DPScrollNumberLabel alloc] initWithNumber:@(0) fontSize:46.0 signSetting:SignSettingUnsigned];
_pointsLab.minRowNumber = 1;
}
return _pointsLab;
}
......
......@@ -55,7 +55,7 @@
[self.beizerView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(self.cardIV);
make.bottom.equalTo(self.cardIV).offset(-36);
make.height.equalTo(@76);
make.top.equalTo(self.cardIV).offset(38);
}];
}
return self;
......@@ -151,7 +151,7 @@
_beizerView = [[BeizerView alloc]initWithFrame:CGRectZero];
_beizerView.x = 50;
_beizerView.y = 50;
_beizerView.radius = 40;
// _beizerView.radius = 40;
_beizerView.backgroundColor = DSClearColor;
// [_beizerView debugViewShowBorder];
// _beizerView.layer.anchorPoint = CGPointMake(0.5, 0.5);
......
......@@ -7,17 +7,17 @@
<key>AFNetworking.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>18</integer>
<integer>8</integer>
</dict>
<key>DKNightVersion.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>19</integer>
<integer>10</integer>
</dict>
<key>DOUAudioStreamer.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>16</integer>
<integer>12</integer>
</dict>
<key>FreeStreamer.xcscheme_^#shared#^_</key>
<dict>
......@@ -27,7 +27,7 @@
<key>IQKeyboardManager.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>11</integer>
<integer>5</integer>
</dict>
<key>MBProgressHUD.xcscheme_^#shared#^_</key>
<dict>
......@@ -37,47 +37,47 @@
<key>MJRefresh.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>12</integer>
<integer>13</integer>
</dict>
<key>Masonry.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>10</integer>
<integer>18</integer>
</dict>
<key>Pods-DreamSleep.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>14</integer>
<integer>4</integer>
</dict>
<key>Reachability.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>5</integer>
<integer>7</integer>
</dict>
<key>YYCache.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>7</integer>
<integer>15</integer>
</dict>
<key>YYImage.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>8</integer>
<integer>14</integer>
</dict>
<key>YYModel.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>13</integer>
<integer>16</integer>
</dict>
<key>YYWebImage.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>15</integer>
<integer>19</integer>
</dict>
<key>lottie-ios.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>6</integer>
<integer>11</integer>
</dict>
</dict>
</dict>
......
......@@ -12,7 +12,7 @@
<key>UnityFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>4</integer>
<integer>6</integer>
</dict>
</dict>
</dict>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!