先看看UIBezierPath的基础概念
UIBezierPath是CGPathRef数据类型的封装。使用UIBezierPath可以创建基于矢量的路径,此类是Core Graphics框架关于路径的封装。使用此类可以定义简单的形状,如椭圆、矩形或者有多个直线和曲线段组成的形状等
所以在这里我想到的是用UIBezierPath进行绘图实现
.h(先引入QuartzCore/QuartzCore.h框架)
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
@interface RMProgressView : UIView
@property (strong, nonatomic) UIColor *trackColor;// 默认轨迹填充颜色
@property (strong, nonatomic) UIColor *progressColor;// 加载条填充颜色
@property (assign, nonatomic) float progress;// 比率
@property (assign, nonatomic) float progressWidth;// 加载条宽度
- (void)setProgressAnimated:(BOOL)animated;
@end
.m
#import "RMProgressView.h"
@interface RMProgressView ()
{
CAShapeLayer *_trackLayer;
UIBezierPath *_trackPat