效果如下:
直接创建 同类名,全选—复制—粘贴 就能完成
文件全代码都有
封装一个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