#import <UIKit/UIKit.h>

@interface ZSDProgressView : UIView
{
UIView *progressView;//进度view
}
//进度值
@property(nonatomic,assign)float progress;
@end
#define UIColorFromRGB(rgbValue) [UIColor \
colorWithRed:((float)((rgbValue & 0xFF0000) >> ))/255.0 \
green:((float)((rgbValue & 0xFF00) >> ))/255.0 \
blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
#import "ZSDProgressView.h"
@implementation ZSDProgressView -(id)initWithFrame:(CGRect)frame
{
if (self=[super initWithFrame:frame])
{
self.backgroundColor=UIColorFromRGB(0xDADADA);
} return self;
}
-(void)awakeFromNib
{ self.backgroundColor=UIColorFromRGB(0xDADADA);
progressView=[[UIView alloc]init];
progressView.translatesAutoresizingMaskIntoConstraints=NO;
[self addSubview:progressView]; }
-(void)setProgress:(float)progress
{
_progress=progress; /**
* activePartView添加约束
*/ //左边约束
[self addConstraint:[NSLayoutConstraint constraintWithItem:progressView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier: constant:]]; //上边约束
[self addConstraint:[NSLayoutConstraint constraintWithItem:progressView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop multiplier: constant:]]; //高度约束
[self addConstraint:[NSLayoutConstraint constraintWithItem:progressView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeHeight multiplier: constant:self.frame.size.height]]; //宽度约束
NSLayoutConstraint *widthCon = [NSLayoutConstraint constraintWithItem:progressView
attribute:NSLayoutAttributeWidth
relatedBy:NSLayoutRelationEqual
toItem:self
attribute:NSLayoutAttributeWidth
multiplier:_progress
constant:];
[self addConstraint:widthCon]; //用背景图来填充背景颜色
UIImage *bgImage=[UIImage imageNamed:@"invest_jindu"];
UIColor *bgColor=[UIColor colorWithPatternImage:bgImage];
[progressView setBackgroundColor:bgColor];
//更新约束
[progressView needsUpdateConstraints]; } @end
#import "ViewController.h"
#import "ZSDProgressView.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet ZSDProgressView *progressView; @end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)setBtnClick:(UIButton *)sender
{ _progressView.progress=0.6; } @end

iOS 实现进度条(progress)的更多相关文章

  1. amazeui学习笔记--css(常用组件13)--进度条Progress

    amazeui学习笔记--css(常用组件13)--进度条Progress 一.总结 1.进度条基本使用:进度条组件,.am-progress 为容器,.am-progress-bar 为进度显示信息 ...

  2. [iOS]圆形进度条及计时功能

    平时用战网安全令的时候很喜欢圆形倒计时的效果,然后简单看了一下Android的圆形进度条,后来又写了一个IOS的.整体界面参照IOS系统的倒计时功能,顺便熟悉了UIPickerView的一些特性的实现 ...

  3. iOS 渐变进度条

    #import <UIKit/UIKit.h> @interface JianBianView : UIView //为了增加一个表示进度条的进行,可们可以使用mask属性来屏蔽一部分 @ ...

  4. iOS 自定义进度条

    自定义条形进度条(iOS) ViewController.m文件 #import "ViewController.h" @interface ViewController () @ ...

  5. IOS 圆形进度条

    // // CCProgressView.h // Demo // // Created by leao on 2017/8/7. // Copyright © 2017年 zaodao. All r ...

  6. 详解HTML5中的进度条progress元素简介及兼容性处理

    一.progress元素基本了解 1.基本知识 progress元素属于HTML5家族,指进度条.IE10+以及其他靠谱浏览器都支持. 注释:Internet Explorer 9 以及更早的版本不支 ...

  7. iOS 环形进度条

    .h文件 #import <UIKit/UIKit.h> @interface YTProgressView : UIView@property (nonatomic, copy) NSS ...

  8. vue 渐变 进度条 progress

    废话 不多少说 ,直接上代码 新建文件 gradual-progress.vue <!-- * @Author: gfc * @Date: 2019-11-07 14:00:11 * @Last ...

  9. 【原】Github系列之三:开源iOS下 渐变颜色的进度条WGradientProgress

    概述 今天我们来实现一个iOS平台上的进度条(progress bar or progress view).这种进度条比APPLE自带的更加漂亮,更加有“B格”.它拥有渐变的颜色,而且这种颜色是动态移 ...

随机推荐

  1. how to javafx hide background header of a tableview?

    http://stackoverflow.com/questions/12324464/how-to-javafx-hide-background-header-of-a-tableview ———— ...

  2. 2013年度Python Git工具

    Pycoders周刊根据读者对周刊文章的点击数据,评选出了2013年最受关注的和Git相关的Python工具. git-workflow (github.com) 可视化你的 git 工作流程的工具, ...

  3. linux下 ls 排序

    ls -lS                       按大小降序排列 ls -l | sort -n -k5    按大小升序 ls -lrt                       按时间降 ...

  4. zoj3591 Nim(Nim博弈)

    ZOJ 3591 Nim(Nim博弈) 题目意思是说有n堆石子,Alice只能从中选出连续的几堆来玩Nim博弈,现在问Alice想要获胜有多少种方法(即有多少种选择方式). 方法是这样的,由于Nim博 ...

  5. UVa11235 FrequentValues(RMQ)

    Problem F: Frequent values You are given a sequence of n integers a1 , a2 , ... , an in non-decreasi ...

  6. POJ1201Intervals(差分约束系统)

    昨天看了下差分约数系统的含义,其实就是如果有n个变量在m个形如aj-ai>=bk条件下,求解的此不等式的方法. 而这种不等式的解法其实就是转化为图论的最小路的算法求解的.我们将上面的不等式边形后 ...

  7. c#学习之旅------01

    一.交换两个数的值 //交换两个数的值 #region 方法一 , num2 = ;//待交换的两个数值 int temp;//临时变量 temp = num1; num1 = num2; num2 ...

  8. 转载:Flash AS3.0 加载外部资源(图片,MP3,SWF)的两种方式

    Flash AS3.0 加载外部资源(图片,MP3,SWF)的两种方式 出自:http://www.cnblogs.com/top5/archive/2012/08/04/2623464.html 关 ...

  9. java懒汉式单例遇到多线程

    单例模式确保某个类只有一个实例,而且自行实例化并向整个系统提供这个实例. 在计算机系统中,线程池.缓存.日志对象.对话框.打印机.显卡的驱动程序对象常被设计成单例.这些应用都或多或少具有资源管理器的功 ...

  10. svn 冲突解决

    svn: E155015: Aborting commit: '$path + $file' remains in conflict 解决步骤 1.svn resolved 'file'执行后结果Re ...