#import <UIKit/UIKit.h>

@interface TJProgressView : UIView
@property(nonatomic,assign)CGFloat progressValue;
- (void)showInView:(UIView *)baseView;
@end
//
// TJProgressView.m
// CurveProgressDemo
//
// Created by MJ on 15/6/12.
// Copyright (c) 2015年 SNWFMJ. All rights reserved.
// #import "TJProgressView.h"
#define kContainerViewSize CGSizeMake(30.f, 25.f)
#define kPadding 5.f
@interface TJProgressView ()
{
UIView *leftView;
UIView *middleView;
UIView *rightView;
UIView *containerView; }
@end
@implementation TJProgressView
- (instancetype)init
{
if (self = [super init])
{
[self setUp];
}
return self;
}
- (void)setUp
{
containerView = [[UIView alloc ]init];
containerView.translatesAutoresizingMaskIntoConstraints = NO;
containerView.backgroundColor = [UIColor clearColor];
[self addSubview:containerView];
NSArray *containerView_H = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|[containerView]|" options: metrics:nil views:NSDictionaryOfVariableBindings(containerView)];
NSArray *containerView_V = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|[containerView]|" options: metrics:nil views:NSDictionaryOfVariableBindings(containerView)];
[self addConstraints:containerView_H];
[self addConstraints:containerView_V]; [self test]; }
- (void)test
{
leftView = [[UIView alloc]init];
leftView.translatesAutoresizingMaskIntoConstraints = NO;
leftView.backgroundColor = [UIColor yellowColor];
[containerView addSubview:leftView];
NSArray *leftView_V = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|[leftView]|" options: metrics:nil views:NSDictionaryOfVariableBindings(leftView)];
[containerView addConstraints:leftView_V]; middleView = [[UIView alloc]init];
middleView.translatesAutoresizingMaskIntoConstraints = NO;
middleView.backgroundColor = [UIColor redColor];
[containerView addSubview:middleView];
NSArray *middleView_V = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|-10-[middleView]|" options: metrics:nil views:NSDictionaryOfVariableBindings(middleView)];
[containerView addConstraints:middleView_V]; rightView = [[UIView alloc]init];
rightView.translatesAutoresizingMaskIntoConstraints = NO;
rightView.backgroundColor = [UIColor blueColor];
[containerView addSubview:rightView];
NSArray *rightView_V = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|[rightView]|" options: metrics:nil views:NSDictionaryOfVariableBindings(rightView)];
[containerView addConstraints:rightView_V];
NSDictionary *dic_paddingConstraint = @{
@"padding":@(kPadding) };
NSArray *allView_H = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[leftView]-padding-[middleView(leftView)]-padding-[rightView(middleView)]-0-|" options: metrics:dic_paddingConstraint views:NSDictionaryOfVariableBindings(leftView,middleView,rightView)];
[containerView addConstraints:allView_H]; }
- (void)showInView:(UIView *)baseView
{
NSDictionary *dic_selfConstraint = @{
@"height":@(kContainerViewSize.height),
@"width":@(kContainerViewSize.width) };
self.translatesAutoresizingMaskIntoConstraints = NO;
[baseView addSubview:self]; NSLayoutConstraint *self_CenterX = [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:baseView attribute:NSLayoutAttributeCenterX multiplier: constant:];
NSLayoutConstraint *self_CenterY = [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:baseView attribute:NSLayoutAttributeCenterY multiplier: constant:]; NSArray *self_H = [NSLayoutConstraint constraintsWithVisualFormat:@"H:[self(width)]" options: metrics:dic_selfConstraint views:NSDictionaryOfVariableBindings(self)];
NSArray *self_V = [NSLayoutConstraint constraintsWithVisualFormat:@"V:[self(height)]" options: metrics:dic_selfConstraint views:NSDictionaryOfVariableBindings(self)]; [baseView addConstraints:@[self_CenterX,self_CenterY]];
[baseView addConstraints:self_H];
[baseView addConstraints:self_V]; }
- (void)setProgressValue:(CGFloat)progressValue
{
_progressValue = progressValue; [self addAnimation:containerView.layer progressValue:_progressValue]; }
- (void)addAnimation:(CALayer *)layer progressValue:(CGFloat)value
{
CABasicAnimation *leftAnimation = [CABasicAnimation animationWithKeyPath:@"position.y"];
leftAnimation.fromValue =@;
leftAnimation.toValue = @(value*kContainerViewSize.height);
leftAnimation.repeatCount = MAXFLOAT;
leftAnimation.duration = 0.5f; [layer addAnimation:leftAnimation forKey:@"test"];
} @end //
// ViewController.m
// CurveProgressDemo
//
// Created by MJ on 15/6/12.
// Copyright (c) 2015年 SNWFMJ. All rights reserved.
// #import "ViewController.h"
#import "TJProgressView.h"
@interface ViewController ()
{
TJProgressView *progressView;
}
@end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad]; progressView = [[TJProgressView alloc]init];
[progressView showInView:self.view]; [NSTimer scheduledTimerWithTimeInterval: target:self selector:@selector(changeValue) userInfo:nil repeats:YES]; } - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; }
- (void)changeValue
{
progressView.progressValue =0.5;
}
@end

CABasicAnimation - 上下滑动动画的更多相关文章

  1. jQuery实用小技巧-获取选中的的下拉框和返回头部滑动动画

    //获取选中的下拉框 $('#someElement').find('option:selected'); $('#someElement option:selected'); //返回头部滑动动画 ...

  2. Android滑动动画ViewFlipper和视频播放VideoView的使用

    Android滑动动画,可以用ViewPager或者ViewFlipper实现. ViewPager自带触摸滑动功能,结合Fragment使用很好,来自补充组件android-support-v4.j ...

  3. 利用jquery实现百度新闻导航菜单滑动动画

    前言 前两天,群里有人问百度新闻导航是如何实现的,当时由于忙于工作,没有来得及细看,恰好今天有空闲时间,索性就实现一下这个效果吧: 思路与步骤 1.利用UL创建简单横向导航: <!DOCTYPE ...

  4. viewpager处理(二):设置当前item时,让viewpager不出现滑动动画

    我们在使用viewpager.setCurrentItem(position);的时候,viewpager出现滑动动画,如何去掉这个动画呢? 可以用viewpager.setCurrentItem(p ...

  5. android仿微信红包动画、Kotlin综合应用、Xposed模块、炫酷下拉视觉、UC浏览器滑动动画等源码

    Android精选源码 仿微信打开红包旋转动画 使用Kotlin编写的Android应用,内容你想象不到 Android手机上的免Root Android系统日志Viewer 一个能让微信 Mater ...

  6. 【Web】利用jquery实现百度新闻导航菜单滑动动画

    前言 前两天,群里有人问百度新闻导航是如何实现的,当时由于忙于工作,没有来得及细看,恰好今天有空闲时间,索性就实现一下这个效果吧: 思路与步骤 1.利用UL创建简单横向导航: <!DOCTYPE ...

  7. JQuery--基础动画、滑动动画、淡入淡出动画、自定义动画

    /** * [JQ基础动画] * show() 显示 * hide() 隐藏 * toggle() 切换 * 默认无动画,如果要产生动画 * 在括号内,添加毫秒数,可产生动画和控制动画的快慢 * * ...

  8. Android的Activity屏幕切换滑动动画

    Activity的切换效果使用的是Android的动画效果,Android的动画在官方有相关资料:http://developer.android.com/guide/topics/graphics/ ...

  9. jQuery 代码的层定位滑动动画效果

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

随机推荐

  1. js 简单模板引擎

    代码 <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" cont ...

  2. P2639 [USACO09OCT]Bessie的体重问题 【背包问题】

    题目描述 Bessie像她的诸多姊妹一样,因为从Farmer John的草地吃了太多美味的草而长出了太多的赘肉.所以FJ将她置于一个及其严格的节食计划之中.她每天不能吃多过H (5 <= H & ...

  3. iptables简单了解

    简介 Iptables是unix/linux自带的一款优秀且开源的基于包过滤的防火墙工具. 怎么用 可以用来做主机防火墙. 可以做局域网共享上网. 可以做ip及端口映射. Iptables工作流程 i ...

  4. 00.模块1.模块(Module)和包(Package)

    转自廖雪峰老师官方网站 在计算机程序的开发过程中,随着程序代码越写越多,在一个文件里代码就会越来越长,越来越不容易维护. 为了编写可维护的代码,我们把很多函数分组,分别放到不同的文件里,这样,每个文件 ...

  5. 百度编辑器ueditor1.4.3配置记录

    我从官网下载的php文件,但是图片上传不能用,后来查找资料,打开ueditor下的php/controller.php,(其他环境选对应的文件夹)把时区设置按如下改个字母大小写,再打开该文件就正确返回 ...

  6. shell 读取目录指定文件并截取拼接

    shell脚本读取指定文件并拼接成指定的版本信息

  7. 【Codeforces Global Round 1 C】Meaningless Operations

    [链接] 我是链接,点我呀:) [题意] 给你一个a 让你从1..a-1的范围中选择一个b 使得gcd(a^b,a&b)的值最大 [题解] 显然如果a的二进制中有0的话. 那么我们就让选择的b ...

  8. Codeforces Round #413(Div. 1 + Div. 2, combined)——ABCD

    题目在这里 A.Carrot Cakes 乱七八糟算出两个时间比较一下就行了 又臭又长仅供参考 #include <bits/stdc++.h> #define rep(i, j, k) ...

  9. Android学习总结(5)——9个非常有用的Andorid 程序片段

    一,获取系统版本号: PackageInfo info = this.getPackageManager().getPackageInfo(this.getPackageName(), 0); int ...

  10. [BZOJ 4999]This Problem Is Too Simple!

    [BZOJ 4999]This Problem Is Too Simple! 题目 给您一颗树,每个节点有个初始值. 现在支持以下两种操作: 1. C i x(0<=x<2^31) 表示将 ...