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格”.它拥有渐变的颜色,而且这种颜色是动态移 ...
随机推荐
- $watch How the $apply Runs a $digest
作者:junyuecao | 发表于 8-8 13:39 | 最后更新时间:8-9 02:34 原文地址:http://angular-tips.com/blog/2013/08/watch-how- ...
- PhysX
[PhysX] 1.施加力: ))) { //施加一个力,X轴方向力度为1000,Y轴方向力度为1000 addFrceObj.rigidbody.AddForce (, , ); } ))) { / ...
- java应用maven插件动态生成webservice代码
pom.xml如下 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www ...
- [iOS微博项目 - 2.6] - 获取微博数据
github: https://github.com/hellovoidworld/HVWWeibo A.新浪获取微博API 1.读取微博API 2.“statuses/home_time ...
- mysql show命令集合
a. show tables或show tables from database_name; -- 显示当前数据库中所有表的名称b. show databases; -- 显示mysql中所有数据库的 ...
- class bool
class bool(int): """ bool(x) -> bool Returns True when the argument x is true, Fal ...
- bmp格式解析
最近一直在写图像处理的作业,好多啊 bmp格式简介 a.格式组成 1:位图头文件数据结构,它包含BMP图像文件的类型.显示内容等信息: 2:位图信息数据结构,它包含有BMP图像的宽.高.压缩方法,以及 ...
- 访问ControlTemplate内部的元素
需要用到code behind 注意要给需要访问的元素命名x:Name="PART_TextBlock" <ResourceDictionary xmlns="ht ...
- jquery 应用小结
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- MFC打开文件对话框
{ CString FilePathName; CFileDialog dlg(TRUE);///TRUE为OPEN对话框,FALSE为SAVE AS对话框 if(dlg.DoModal()==IDO ...