#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. HDU 5489 Removed Interval (LIS变形)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5489 给你n个数,要删去其中连续的L个,问你删去之后的LIS最大是多少? 我们先预处理出以i下标为开头 ...

  2. LIS LCS n^2和nlogn解法 以及LCIS

    首先介绍一下LIS和LCS的DP解法O(N^2) LCS:两个有序序列a和b,求他们公共子序列的最大长度 我们定义一个数组DP[i][j],表示的是a的前i项和b的前j项的最大公共子序列的长度,那么由 ...

  3. HDU 3364 Lanterns (高斯消元)

    题意:有n个灯和m个开关,每个开关控制数个灯的状态改变,给出k条询问,问使灯的状态变为询问中的状态有多少种发法. 析:同余高斯消元法,模板题,将每个开关控制每个灯列成行列式,最终状态是结果列,同余高斯 ...

  4. Spring REST实践之Versioning,Paging和Sorting

    Versioning 为适应需求的变化以及兼容已有的API,需要创建新版本的API,一般有四种流行的版本化API的方法: URI版本化 URI参数版本化 Accept header版本化 自定义hea ...

  5. 选择一本C++教材

    从上周开始写如何使用C++编程以后,我发现这不是一个容易的题目.因此,我认真的看了一下C++相关的材料,发现现在为止,比较好的材料还是这些: 初学者: Accelerated C++,这是一本学习起来 ...

  6. Linux下生成动态链接库是否必须使用 -fPIC 的问题[转]

    在 Linux 下制作动态链接库,“标准” 的做法是编译成位置无关代码(Position Independent Code,PIC),然后链接成一个动态链接库.经常遇到的一个问题是 -fPIC 是不是 ...

  7. 事件委托&jQuery on

    例如: <h2>Great Web resources</h2> <ul id="resources"> <li><a hre ...

  8. PHP函数前面的@。

    @是可以屏蔽函数执行过程中遇到问题而产生的一些错误.警告信息,这样用户就看不到程序的出错信息.这样除了用户界面会友好一些外,更重要的是安全性,因为屏蔽了出错文件的路径等信息. 比如说这个: for($ ...

  9. Apache开启伪静态后报500错误.

    参考:http://blog.163.com/lgh_2002/blog/static/44017526201051452939761/ 加载Rewrite模块: 在conf目录下httpd.conf ...

  10. 手游产品经理初探(六)粗糙的logo会给产品致命一击

    假设你的游戏产品从logo的设计開始就不注重细节的话,那么你的产品将不会走多远! 我们把图片放大看: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbGl1 ...