iOS仿支付宝芝麻信用分数仪表盘动画效果

先看看效果图:

仪表盘动画效果.jpg

1.圆环上绿点的旋转

2.分数值及提示语的变化

3.背景色的变化

直接上主要代码:

1.自定义ZLDashboardView仪表盘文件:

.h 文件:

/**
 * 根据跃动数字
 *
 * 确定百分比
 * 现在的跳动数字——>背景颜色变化
 *
 */

#import <UIKit/UIKit.h>
@interface ZLDashboardView : UIView
@property (nonatomic, strong) UIImage *bgImage;
@property (nonatomic, copy) void(^TimerBlock)(NSInteger);

/**
 * 跃动数字刷新
 *
 */
- (void)refreshJumpNOFromNO:(NSString *)startNO toNO:(NSString *)toNO;

@end

.m 文件

#import "ZLDashboardView.h"
#import "UIView+Extensions.h" 

#define degreesToRadians(x) (M_PI*(x)/180.0) //把角度转换成PI的方式
static const CGFloat kMarkerRadius = 5.f; // 光标直径
static const CGFloat kTimerInterval = 0.03;
static const CGFloat kFastProportion = 0.9;

static const NSInteger MaxNumber = 1000;

@interface ZLDashboardView () {
  CGFloat animationTime;
  NSInteger beginNO;
  NSInteger jumpCurrentNO;
  NSInteger endNO;
}

// 百分比 0 - 100 根据跃动数字设置
@property (nonatomic, assign) CGFloat percent;

@property (nonatomic, strong) CAShapeLayer *bottomLayer; // 进度条底色
@property (nonatomic, assign) CGFloat lineWidth; // 弧线宽度

@property (nonatomic, strong) UIImageView *markerImageView; // 光标

@property (nonatomic, strong) UIImageView *bgImageView; // 背景图片

@property (nonatomic, assign) CGFloat circelRadius; //圆直径
@property (nonatomic, assign) CGFloat startAngle; // 开始角度
@property (nonatomic, assign) CGFloat endAngle; // 结束角度

@property (nonatomic, strong) UILabel *showLable; // 跳跃数字
@property (nonatomic, strong) UILabel *markedLabel; // 提示语
@property (nonatomic, strong) NSTimer *fastTimer;
@property (nonatomic, strong) NSTimer *slowTimer;

@property (nonatomic, assign) NSInteger intervalNum;

@end

@implementation ZLDashboardView

#pragma mark - Life cycle

- (instancetype)initWithFrame:(CGRect)frame {

  self = [super initWithFrame:frame];
  if (self) {
    self.backgroundColor = [UIColor clearColor];

    self.circelRadius = self.frame.size.width - 10.f;
    self.lineWidth = 2.f;
    self.startAngle = -200.f;
    self.endAngle = 20.f;

    // 尺寸需根据图片进行调整
    self.bgImageView.frame = CGRectMake(6, 6, self.circelRadius, self.circelRadius * 2 / 3);
    self.bgImageView.backgroundColor = [UIColor clearColor];
    [self addSubview:self.bgImageView];

    //添加圆框
    [self setupCircleBg];

    //光标
    [self setupMarkerImageView];

    //添加跃动数字 及 提示语
    [self setupJumpNOView];
  }
  return self;
}

- (void)setupCircleBg {

  // 圆形路径
  UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(self.width / 2, self.height / 2)
                            radius:(self.circelRadius - self.lineWidth) / 2
                          startAngle:degreesToRadians(self.startAngle)
                           endAngle:degreesToRadians(self.endAngle)
                           clockwise:YES];

  // 底色
  self.bottomLayer = [CAShapeLayer layer];
  self.bottomLayer.frame = self.bounds;
  self.bottomLayer.fillColor = [[UIColor clearColor] CGColor];
  self.bottomLayer.strokeColor = [[UIColor colorWithRed:206.f / 256.f green:241.f / 256.f blue:227.f alpha:1.f] CGColor];
  self.bottomLayer.opacity = 0.5;
  self.bottomLayer.lineCap = kCALineCapRound;
  self.bottomLayer.lineWidth = self.lineWidth;
  self.bottomLayer.path = [path CGPath];
  [self.layer addSublayer:self.bottomLayer];

// 240 是用整个弧度的角度之和 |-200| + 20 = 220
//  [self createAnimationWithStartAngle:degreesToRadians(self.startAngle)
//                endAngle:degreesToRadians(self.startAngle + 220 * 1)];
}

- (void)setupMarkerImageView {
  if (_markerImageView) {
    return;
  }
  _markerImageView = [[UIImageView alloc] init];
  _markerImageView.backgroundColor = [UIColor clearColor];
  _markerImageView.layer.backgroundColor = [UIColor greenColor].CGColor;
  _markerImageView.layer.shadowColor = [UIColor whiteColor].CGColor;
  _markerImageView.layer.shadowOffset = CGSizeMake(0, 0);
  _markerImageView.layer.shadowRadius = kMarkerRadius*0.5;
  _markerImageView.layer.shadowOpacity = 1;
  _markerImageView.layer.masksToBounds = NO;
  self.markerImageView.layer.cornerRadius = self.markerImageView.frame.size.height / 2;
  [self addSubview:self.markerImageView];
  _markerImageView.frame = CGRectMake(-100, self.height, kMarkerRadius, kMarkerRadius);
}

- (void)setupJumpNOView {
  if (_showLable) {
    return;
  }
  CGFloat width = self.circelRadius / 2 + 50;
  CGFloat height = self.circelRadius / 2 - 50;
  CGFloat xPixel = self.bgImageView.left + (self.bgImageView.width - width)*0.5;//self.circelRadius / 4;
  CGFloat yPixel = self.circelRadius / 4;
  CGRect labelFrame = CGRectMake(xPixel, yPixel, width, height);
  _showLable = [[UILabel alloc] initWithFrame:labelFrame];
  _showLable.backgroundColor = [UIColor clearColor];
  _showLable.textColor = [UIColor greenColor];
  _showLable.textAlignment = NSTextAlignmentCenter;
  _showLable.font = [UIFont systemFontOfSize:100.f];
  _showLable.text = [NSString stringWithFormat:@"%ld",jumpCurrentNO];
  [self addSubview:_showLable];

  // 提示语
  _markedLabel = [[UILabel alloc] initWithFrame:CGRectMake(xPixel, CGRectGetMaxY(_showLable.frame), width, 30)];
  _markedLabel.backgroundColor = [UIColor clearColor];
  _markedLabel.textColor = [UIColor greenColor];
  _markedLabel.textAlignment = NSTextAlignmentCenter;
  _markedLabel.font = [UIFont systemFontOfSize:20.f];
  _markedLabel.text = @"营养良好";
  [self addSubview:_markedLabel];
}

#pragma mark - Animation

- (void)createAnimationWithStartAngle:(CGFloat)startAngle endAngle:(CGFloat)endAngle { // 光标动画

  //启动定时器
  [_fastTimer setFireDate:[NSDate distantPast]];
  // 设置动画属性
  CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
  pathAnimation.calculationMode = kCAAnimationPaced;
  pathAnimation.fillMode = kCAFillModeForwards;
  pathAnimation.removedOnCompletion = NO;
  pathAnimation.duration = _percent * kTimerInterval;
  pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
  pathAnimation.repeatCount = 1;

  // 设置动画路径
  CGMutablePathRef path = CGPathCreateMutable();
  CGPathAddArc(path, NULL, self.width / 2, self.height / 2, (self.circelRadius - kMarkerRadius / 2) / 2, startAngle, endAngle, 0);
  pathAnimation.path = path;
  CGPathRelease(path);

  [self.markerImageView.layer addAnimation:pathAnimation forKey:@"moveMarker"];

}

#pragma mark - Setters / Getters

/**
 * 开始动画 确定百分比
 *
 */
- (void)refreshJumpNOFromNO:(NSString *)startNO toNO:(NSString *)toNO {

  beginNO = 0;//[startNO integerValue];
  jumpCurrentNO = 0;//[startNO integerValue];
  endNO = [toNO integerValue];
  _percent = endNO * 100 / MaxNumber;

  NSInteger diffNum = endNO - beginNO;
  if (diffNum <= 0) {
    return;
  }
  if (diffNum < 100) {
    _intervalNum = 5;
  } else if (diffNum < 300) {
    _intervalNum = 15;
  } else if (diffNum <= MaxNumber) {
    _intervalNum = 10;
  }
  NSLog(@"数字间隔:%ld",_intervalNum);

  //数字
  [self setupJumpThings];

  // 设置角度
  NSInteger angle = 0;
  NSInteger num = [toNO floatValue] - [startNO floatValue];
  if (num < 200) {
    angle = self.startAngle + 220 * (num / 200.0) / 5.0;
  } else if (num < 350) {
    angle = self.startAngle + 220 / 5.0 + (3 / 5.0 * 220) * (num - 200) / 150.0;
  } else {
    angle = self.startAngle + 220 / 5.0 * 4 + (220 / 5.0) * (num - 350) / 250.0;
  }

  //光标
  [self createAnimationWithStartAngle:degreesToRadians(self.startAngle)
                endAngle:degreesToRadians(angle)];
}

- (void)setBgImage:(UIImage *)bgImage {

  _bgImage = bgImage;
  self.bgImageView.image = bgImage;
}

- (UIImageView *)bgImageView {

  if (nil == _bgImageView) {
    _bgImageView = [[UIImageView alloc] init];
  }
  return _bgImageView;
}

#pragma mark - 跃动数字

- (void)setupJumpThings {

  animationTime = _percent * kTimerInterval;

  self.fastTimer = [NSTimer timerWithTimeInterval:kTimerInterval*kFastProportion
                       target:self
                      selector:@selector(fastTimerAction)
                      userInfo:nil
                      repeats:YES];
  [[NSRunLoop currentRunLoop] addTimer:_fastTimer forMode:NSRunLoopCommonModes];

  //时间间隔 = (总时间 - 快时间间隔*变化次数)/ 再次需要变化的次数
  //快时间
  NSInteger fastEndNO = endNO * kFastProportion;

  NSInteger fastJump = fastEndNO/_intervalNum;
  if (fastJump % _intervalNum) {
    fastJump++;
    fastEndNO += _intervalNum;
  }
  CGFloat fastTTime = fastJump*kTimerInterval*kFastProportion;

  //剩余应跳动次数
  NSInteger changNO = endNO - fastEndNO;
  NSInteger endJump = changNO / _intervalNum + changNO % _intervalNum;
  //慢时间间隔
  NSTimeInterval slowInterval = (animationTime - fastTTime) / endJump;

  self.slowTimer = [NSTimer timerWithTimeInterval:slowInterval
                       target:self
                      selector:@selector(slowTimerAction)
                      userInfo:nil
                      repeats:YES];
  [[NSRunLoop currentRunLoop] addTimer:_slowTimer forMode:NSRunLoopCommonModes];
  [_fastTimer setFireDate:[NSDate distantFuture]];
  [_slowTimer setFireDate:[NSDate distantFuture]];
}

#pragma mark 加速定时器触发事件
- (void)fastTimerAction {
  if (jumpCurrentNO >= endNO) {
    [self.fastTimer invalidate];
    return;
  }
  if (jumpCurrentNO >= endNO * kFastProportion) {
    [self.fastTimer invalidate];
    [self.slowTimer setFireDate:[NSDate distantPast]];
    return;
  }
  [self commonTimerAction];
}

#pragma mark 减速定时器触发事件
- (void)slowTimerAction {
  if (jumpCurrentNO >= endNO) {
    [self.slowTimer invalidate];
    return;
  }
  [self commonTimerAction];
}

#pragma mark 计时器共性事件 - lable赋值 背景颜色及提示语变化
- (void)commonTimerAction {

  if (jumpCurrentNO % 100 == 0 && jumpCurrentNO != 0) {
    NSInteger colorIndex = jumpCurrentNO / 100;
    dispatch_async(dispatch_get_main_queue(), ^{
      if (self.TimerBlock) {
        self.TimerBlock(colorIndex);
      }
    });
  }
  NSInteger changeValueBy = endNO - jumpCurrentNO;

  if (changeValueBy/10 < 1) {
    jumpCurrentNO++;
  } else {
//    NSInteger changeBy = changeValueBy / 10;
    jumpCurrentNO += _intervalNum;
  }

  _showLable.text = [NSString stringWithFormat:@"%ld",jumpCurrentNO];
  if (jumpCurrentNO < 350) {
    _markedLabel.text = @"营养太差";
  } else if (jumpCurrentNO <= 550) {
    _markedLabel.text = @"营养较差";
  } else if (jumpCurrentNO <= 600) {
    _markedLabel.text = @"营养中等";
  } else if (jumpCurrentNO <= 650) {
    _markedLabel.text = @"营养良好";
  } else if (jumpCurrentNO <= 700) {
    _markedLabel.text = @"营养优秀";
  } else if (jumpCurrentNO <= 950) {
    _markedLabel.text = @"营养较好";
  }
}

@end
在所需的当前控制器里展示:

//
// ViewController.m
// ZLDashboard
//
// Created by qtx on 16/9/19.
// Copyright © 2016年 ZL. All rights reserved.
//

#import "ViewController.h"
#import "ZLDashboardView.h"
#import "ZLGradientView.h"
#import "UIView+Extensions.h"

#define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
#define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)

#define MinNumber 350
#define MaxNumber 950

@interface ViewController ()

@property (nonatomic, strong) ZLDashboardView *dashboardView;

@property (nonatomic, strong) ZLGradientView * gradientView;

@property (nonatomic, strong) UIButton * clickBtn;

@property (nonatomic, strong) UISlider * slider;

@end

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];

  //创建背景色
  [self setupGradientView];

  //创建仪表盘
  [self setupCircleView];

  //添加触发动画的点击button
  [self addActionButton];

  //改变value
  [self addSlideChnageValue];

}

- (void)addActionButton {
  UIButton *stareButton = [UIButton buttonWithType:UIButtonTypeCustom];
  stareButton.frame = CGRectMake(10.f, self.dashboardView.bottom + 50.f, SCREEN_WIDTH - 20.f, 38.f);
  [stareButton addTarget:self action:@selector(onStareButtonClick:) forControlEvents:UIControlEventTouchUpInside];
  [stareButton setTitle:@"Start Animation" forState:UIControlStateNormal];
  [stareButton setBackgroundColor:[UIColor lightGrayColor]];
  stareButton.layer.masksToBounds = YES;
  stareButton.layer.cornerRadius = 4.f;
  [self.view addSubview:stareButton];

  _clickBtn = stareButton;
}

- (void)addSlideChnageValue {

  CGFloat width = 280;
  CGFloat height = 40;
  CGFloat xPixel = (SCREEN_WIDTH - width) * 0.5;
  CGFloat yPixel = CGRectGetMaxY(_clickBtn.frame) + 20;
  CGRect slideFrame = CGRectMake(xPixel, yPixel, width, height);

  UISlider *slider = [[UISlider alloc] initWithFrame:slideFrame];

  slider.minimumValue = MinNumber;
  slider.maximumValue = MaxNumber;

  slider.minimumTrackTintColor = [UIColor colorWithRed:0.000 green:1.000 blue:0.502 alpha:1.000];
  slider.maximumTrackTintColor = [UIColor colorWithWhite:0.800 alpha:1.000];
  /**
   * 注意这个属性:如果你没有设置滑块的图片,那个这个属性将只会改变已划过一段线条的颜色,不会改变滑块的颜色,如果你设置了滑块的图片,又设置了这个属性,那么滑块的图片将不显示,滑块的颜色会改变(IOS7)
   */
  [slider setThumbImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
  slider.thumbTintColor = [UIColor cyanColor];

  [slider setValue:0.5 animated:YES];

  [slider addTarget:self action:@selector(slideTap:)forControlEvents:UIControlEventValueChanged];

  [self.view addSubview:slider];

  _slider = slider;
}

- (void)slideTap:(UISlider *)sender {
  CGFloat value = sender.value;
  NSLog(@"%.f",value);
}

- (void)setupGradientView {
  self.gradientView = [[ZLGradientView alloc] initWithFrame:self.view.bounds];
  [self.view addSubview:self.gradientView];
}

- (void)setupCircleView {
  self.dashboardView = [[ZLDashboardView alloc] initWithFrame:CGRectMake(40.f, 70.f, SCREEN_WIDTH - 80.f, SCREEN_WIDTH - 80.f)];
  self.dashboardView.bgImage = [UIImage imageNamed:@"backgroundImage"];
  [self.view addSubview:self.dashboardView];
}

- (void)onStareButtonClick:(UIButton *)sender {

  if (sender.selected) {
    [self.gradientView removeFromSuperview];
    self.gradientView = nil;
    [self.dashboardView removeFromSuperview];
    self.dashboardView = nil;

    [self setupGradientView];
    [self setupCircleView];

    [self.view bringSubviewToFront:self.clickBtn];
    [self.view bringSubviewToFront:_slider];
  }
  sender.selected = YES;

  CGFloat value = _slider.value;

  NSString *startNO = [NSString stringWithFormat:@"%d", MinNumber];
  NSString *toNO = [NSString stringWithFormat:@"%.f",value];//@"693"; 950
  NSLog(@"endNO:%@",toNO);
  [self.dashboardView refreshJumpNOFromNO:startNO toNO:toNO];

  __block typeof(self)blockSelf = self;
  self.dashboardView.TimerBlock = ^(NSInteger index) {
    [blockSelf.gradientView setUpBackGroundColorWithColorArrayIndex:index];
  };
}

@end

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我们。

(0)

相关推荐

  • 支付宝支付开发IOS图文教程案例

    前言:继上次<微信支付开发IOS图文教程案例>以来,一直没有太多时间,更新总结详细支付这样的长篇大论,很抱歉.今天,推出支付宝支付的详细流程. 1.开始下载和查看支付宝支付的Demo. 我们直接进入支付宝的支付平台参考来进行集成支付宝支付: https://doc.open.alipay.com/doc2/detail.htm?spm=a219a.7629140.0.0.jIUkAQ&treeId=59&articleId=103675&docType=1 集成过程基本

  • iOS开发支付宝支付成功返回字符串的处理操作

    { memo=""; result="partner=\"311811\"&seller_id=\"nse@gmail.com\"&out_trade_no=\"S005372\"&subject=\"\U522b\U5885\U8ba2\U5355\"&body=\"\U5885\"&total_fee=\"0.1\"

  • IOS 仿支付宝支付屏幕亮度变化机制

    1.首先,在需要实现的界面viewDidLoad中先保存亮度没有变化之前的亮度,因为这个界面消失之后还要变回原来的亮度,变化亮度也相当于用户的一种设置,所以也要保存一下这个状态,因为之后当APP在active和非active切换时候需要知道是否需要为用户做这个功能 // 保存原来的亮度 [[NSUserDefaults standardUserDefaults] setObject:@([UIScreen mainScreen].brightness) forKey:@"brightness&q

  • iOS实现类似微信和支付宝的密码输入框(UIKeyInput协议)

    目前在项目中需要实现发红包的功能,自己就写了一个密码输入框的控件,主要用到了UIKeyInput协议和CoreGraphics框架,效果类似微信支付,感觉还行就把我的思路和制作过程写下来给大家分享一下. 让你的自定义View具备输入的功能(UIKeyInput协议) 通过UIKeyInput协议可以为响应者提供简单的键盘输入的功能,让需要键盘的responder成为第一响应者就行了.UIKeyInput协议必须实现的有三个方法,分别是以下方法: #pragma mark - UIKeyInput

  • iOS支付宝使用方法详解

    支付宝相关资源下载地址:支付宝开放平台 在移动支付功能处下载. 一.使用官方的Demo 需要配置基本信息: 打开"APViewController.m"文件,对以下三个参数进行编辑. 二.集成支付宝到自己的工程 1.启动Xcode,为了方便快速开发,将解压包里面的AlipaySDK.bundle和AlipaySDK.framework 和Demo里面的以下文件拷贝到自己的工程文件夹中去,并导入到项目工程中. 2.在Build Phases选项卡的Link Binary With Lib

  • iOS支付宝支付方法详解

    支付宝SDK下载地址:https://doc.open.alipay.com/doc2/detail?treeId=54&articleId=103419&docType=1 支付宝集成 在支付宝集成的过程中,会遇到一些报错,下面就碰到的报错,和大家一起解决. 集成参考官方文档: 导入代码文档:https://doc.open.alipay.com/doc2/detail.htm?spm=0.0.0.0.RiFaVa&treeId=59&articleId=103676&a

  • iOS动画解析之支付宝支付打钩动画的实现方法

    前言 我们平时在用支付宝付款时,会有一个支付中的动画和一个支付完成的动画.这篇博客主要分析一下这种动画效果,效果如下: 支付宝支付动画 一.动画解析 为了方便观察,放慢了动画的速度并添加辅助线: 放慢后的动画 从图中可以看出:加载圆弧运动轨迹可分为前半段和后半段:并且圆弧的起始角度(StartAngle)和结束角度(EndAngle)在做有规律的变化: 前半段: 从-0.5π到π,这一段运动中速度较快:StartAngle不变,始终未-0.5π:EndAngle在匀速上升,一直到π:前半段中圆弧

  • iOS仿支付宝芝麻信用分数仪表盘动画效果

    先看看效果图: 仪表盘动画效果.jpg 1.圆环上绿点的旋转 2.分数值及提示语的变化 3.背景色的变化 直接上主要代码: 1.自定义ZLDashboardView仪表盘文件: .h 文件: /** * 根据跃动数字 * * 确定百分比 * 现在的跳动数字-->背景颜色变化 * */ #import <UIKit/UIKit.h> @interface ZLDashboardView : UIView @property (nonatomic, strong) UIImage *bgIm

  • js canvas仿支付宝芝麻信用分仪表盘

    这是一个仿支付宝芝麻信用分的一个canvas,其实就是一个动画仪表盘. 首先, 上原图: 这个是在下支付宝上的截图,分低各位见笑了.然后看下我用canvas实现的效果图: <canvas id="canvas" width="400" height="700" data-score='724'></canvas> <!-- 设置data-score,分数区间[400, 900] --> 唉,总感觉不像.这个是G

  • Android自定义View仿支付宝芝麻信用分仪表盘

    先看下iOS的芝麻信用分截图 这是我做的效果,还是有点差距的 支付宝9.9版本芝麻信用分的实现 首先初始化各种画笔,默认的size,padding,小圆点. (因为实在找不到原版芝麻信用的带点模糊效果的小圆点,所以只好用这个代替) //View的默认大小 defaultSize = dp2px(250); //默认Padding大小 arcDistance = dp2px(14); //外层圆环画笔 mMiddleArcPaint = new Paint(Paint.ANTI_ALIAS_FLA

  • Android自定义view之仿支付宝芝麻信用仪表盘示例

    自定义view练习 仿支付宝芝麻信用的仪表盘 对比图: 首先是自定义一些属性,可自己再添加,挺基础的,上代码 <?xml version="1.0" encoding="utf-8"?> <resources> <declare-styleable name="RoundIndicatorView"> <!--最大数值--> <attr name="maxNum" form

  • Android仿支付宝中余额宝的数字动画效果

    实现效果图: 下面是具体代码,可直接复制: package com.lcw.rabbit.widget; import android.animation.ObjectAnimator; import android.content.Context; import android.text.TextUtils; import android.util.AttributeSet; import android.view.animation.AccelerateDecelerateInterpola

  • iOS仿抖音视频加载动画效果的实现方法

    前言 这几天一直跟开源的抖音demo斗智斗勇,今天跟大家分享的是抖音中或者快手中加载视频的动画,这个加载效果还是挺实用,下面话不多说了,来随着小编一起学习学习吧 上图看成品 实现原理 首先我创建一个视图 @interface ViewController () @property (nonatomic, strong) UIView *playLoadingView; @end @implementation ViewController - (void)viewDidLoad { [super

  • Android仿支付宝笑脸刷新加载动画的实现代码

    看到支付宝的下拉刷新有一个笑脸的动画,因此自己也动手实现一下.效果图如下: 一.总体思路 1.静态部分的笑脸. 这一部分的笑脸就是一个半圆弧,加上两颗眼睛,这部分比较简单,用于一开始的展示. 2.动态笑脸的实现. 2.1.先是从底部有一个圆形在运动,运动在左眼位置时把左眼给绘制,同时圆形继续运动,运动到右眼位置时绘制右眼,圆形继续运动到最右边的位置. 2.2.当上面的圆形运动到最右边时候,开始不断绘制脸,从右向左,脸不断增长,这里脸设置为接近半个圆形的大小. 2.3.当脸画完的时候,开始让脸旋转

  • iOS高仿微信相册界面翻转过渡动画效果

    点开微信相册的时候,想要在相册图片界面跳转查看点赞和评论时,微信会采用界面翻转的过渡动画来跳转到评论界面,好像是在图片界面的背面一样,点击完成又会翻转回到图片界面,这不同于一般的导航界面滑动动画,觉得很有意思,于是自己学着做了一下,其实也很简单,下面是实现的类似的效果图: 在图片界面点击右下角的查看评论会翻转到评论界面,评论界面点击左上角的返回按钮会反方向翻转回图片界面,真正的实现方法,与传统的导航栏过渡其实只有一行代码的区别,让我们来看看整体的实现. 首先我们实现图片界面,这个界面上有黑色的背

  • Android自定义ViewGroup实现绚丽的仿支付宝咻一咻雷达脉冲效果

    去年春节的时候支付宝推行的集福娃活动着实火的不能再火了,更给力的是春晚又可以全民参与咻一咻集福娃活动,集齐五福就可平分亿元大红包,只可惜没有敬业福--那时候在家没事写了个咻一咻插件,只要到了咻一咻的时间点插件就可以自动的点击咻一咻来咻红包,当时只是纯粹练习这部分技术代码没有公开,后续计划写篇关于插件这方面的文章,扯远了(*^__^*) --我们知道在支付宝的咻一咻页面有个雷达扩散的动画效果,当时感觉动画效果非常棒,于是私下尝试着实现了类似的效果,后来在github发现有大神也写有类似效果,于是读

随机推荐