有渐变色的进度圆环(带有百分比)

本文介绍了如何实现一个具有渐变色效果的进度圆环,并且显示百分比。通过封装一个view,可以方便地在项目中直接使用。提供了相应的.h和.m文件代码示例,只需复制粘贴即可生成类似效果。
摘要由CSDN通过智能技术生成

效果如下:
这里写图片描述

直接创建 同类名,全选—复制—粘贴 就能完成
文件全代码都有
封装一个view 直接使用

使用例子:
即为效果图


    ZPCAshapelGradientView *view = [[ZPCAshapelGradientView alloc] initWithFrame:CGRectMake(40, 100, 300, 300)];
//    view.progressLineWidth = 90;//最大是45
//    view.startAngle = -210;
//    view.endAngle = 30;
//    view.biggerTitle = @"属性居中,字体大小和颜色可以改变,自身大小为半径减去线宽,最好是 字少一些";
    view.biggerLabel.font = [UIFont systemFontOfSize:40];
    [self.view addSubview:view];

*.h文件

//
//  ZPCAshapelGradientView.h
//  table
//
//  Created by 郑鹏 on 16/8/7.
//  Copyright © 2016年 郑鹏. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface ZPCAshapelGradientView : UIView

@property (nonatomic,strong)CAShapeLayer *trackLayer;//背景轨迹 层
@property (nonatomic,strong)CAShapeLayer *progressLayer;//上面的可视层  (改到.h文件  是因为  根据需要改变它的渲染程度时,是在外面进行的。)

@property (nonatomic,assign)CGFloat progressLineWidth;//环宽  默认是 15 最大是45(再大 多彩拼接缝隙能被看到 不美观)

//开始的角度数
@property (nonatomic,assign)CGFloat startAngle;
//结束的角度数
@property (nonatomic,assign)CGFloat endAngle;

@property (nonatomic,copy)NSString *biggerTitle;

@property (nonatomic,copy)NSString *smallerTitle;

@property (nonatomic,strong)UIView *bgView;//大view
@property (nonatomic,strong)UILabel *biggerLabel;//大标题 label



@end

.m文件*

//
//  ZPCAshapelGradientView.m
//  table
//
//  Created by 郑鹏 on 16/8/7.
//  Copyright © 2016年 郑鹏. All rights reserved.
//

**#import "ZPCAshapelGradientView.h"
define degreesToRadians(x) (M_PI*(x)/180.0) //把角度转换成PI的方式
de
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值