iOS 实现进度条(progress)
#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)的更多相关文章
- amazeui学习笔记--css(常用组件13)--进度条Progress
amazeui学习笔记--css(常用组件13)--进度条Progress 一.总结 1.进度条基本使用:进度条组件,.am-progress 为容器,.am-progress-bar 为进度显示信息 ...
- [iOS]圆形进度条及计时功能
平时用战网安全令的时候很喜欢圆形倒计时的效果,然后简单看了一下Android的圆形进度条,后来又写了一个IOS的.整体界面参照IOS系统的倒计时功能,顺便熟悉了UIPickerView的一些特性的实现 ...
- iOS 渐变进度条
#import <UIKit/UIKit.h> @interface JianBianView : UIView //为了增加一个表示进度条的进行,可们可以使用mask属性来屏蔽一部分 @ ...
- iOS 自定义进度条
自定义条形进度条(iOS) ViewController.m文件 #import "ViewController.h" @interface ViewController () @ ...
- IOS 圆形进度条
// // CCProgressView.h // Demo // // Created by leao on 2017/8/7. // Copyright © 2017年 zaodao. All r ...
- 详解HTML5中的进度条progress元素简介及兼容性处理
一.progress元素基本了解 1.基本知识 progress元素属于HTML5家族,指进度条.IE10+以及其他靠谱浏览器都支持. 注释:Internet Explorer 9 以及更早的版本不支 ...
- iOS 环形进度条
.h文件 #import <UIKit/UIKit.h> @interface YTProgressView : UIView@property (nonatomic, copy) NSS ...
- vue 渐变 进度条 progress
废话 不多少说 ,直接上代码 新建文件 gradual-progress.vue <!-- * @Author: gfc * @Date: 2019-11-07 14:00:11 * @Last ...
- 【原】Github系列之三:开源iOS下 渐变颜色的进度条WGradientProgress
概述 今天我们来实现一个iOS平台上的进度条(progress bar or progress view).这种进度条比APPLE自带的更加漂亮,更加有“B格”.它拥有渐变的颜色,而且这种颜色是动态移 ...
随机推荐
- HDU1000
哈哈A+B #include<stdio.h> int main() { int a,b; while(scanf("%d%d",&a,&b)!=EOF ...
- commondline 之二 执行类
E:\cn\zno\commandline\Test.class package cn.zno.commandline; import java.lang.management.ManagementF ...
- 找不到类型或命名空间 datarowview
在绑定数据时经常会用到这个句程序:<%# DataBinder.Eval(Container.DataItem,"xxxx")%>或者<%# DataBinder ...
- android进度条的使用
// 导入按钮事件 btnsearch.setOnClickListener(new View.OnClickListener() { @Override public void on ...
- Java和MongoDB之Hello World
1.新建Project 新建Java Project,并把mongo-java-driver驱动加入到项目bulid path中,如果你使用的是maven增加依赖. <dependency> ...
- 多线程下载网络歌曲&播放歌曲&并用seekbar调节进度&显示歌曲两边的时间
这里先给一个处理时间格式的代码: /** * 时间的处理 * * @param time * @return */ public static String getTimeFromInt(int t ...
- sessionStorage 、localStorage 和 cookie 之间的区别
sessionStorage 和 localStorage 是HTML5 Web Storage API 提供的,可以方便的在web请求之间保存数据.有了本地数据,就可以避免数据在浏览器和服务器间不必 ...
- hdu 1861-游船出租
游船出租 Time Limit: 1 ...
- Beyond Compare3 添加到右键菜单
Beyond Compare 是个优秀的工具,我们经常用于对比文件和文件夹,右键点点就可以调用对比,着实很方便.但从3.2版本之前,我们可以从设置中将bc关联到文件夹和文件右键,但之后的版本已经找不到 ...
- clientTop scrollTop offsetTop
关于top.clientTop.scrollTop.offsetTop的用法 网页可见区域宽: document.body.clientWidth;网页可见区域高: document.body.cli ...