#import <UIKit/UIKit.h>
@interface BezierView : UIView
//根据三个点画圆
-(instancetype)initWithFrame:(CGRect)frameRect P1:(CGPoint)P1 P2:(CGPoint)P2 P3:(CGPoint)P3 color:(UIColor*)color;
@end
@interface BezierViewForPointBigArc : UIView
//根据中心点画圆
-(instancetype)initWithFrame:(CGRect)frameRect P:(CGPoint)P R:(float)R color:(UIColor*)color;
-(void)change:(CGPoint)P R:(float)R color:(UIColor*)color;
@end
@interface BezierViewForPointSmallArc : UIView
//根据中心点画实心圆点
-(instancetype)initWithFrame:(CGRect)frameRect P:(CGPoint)P R:(float)R color:(UIColor*)color;
@end
#pragma mark -
#pragma mark -
@interface BezierViewForPointBigArc(){
//三个分割点
CGPoint sP;
float sR;
//颜色
UIColor *drawColor;
}
@end
@implementation BezierViewForPointBigArc
-(instancetype)initWithFrame:(CGRect)frameRect P:(CGPoint)P R:(float)R color:(UIColor*)color
{
if (self==[super initWithFrame:frameRect]) {
self.backgroundColor = [UIColor clearColor];
sP = P;
sR = R;
drawColor = color;
}
return self;
}
-(void)change:(CGPoint)P R:(float)R color:(UIColor*)color
{
sP = P;
sR = R;
drawColor = color;
[self setNeedsDisplay];
}
- (void)drawRect:(CGRect)rect
{
UIBezierPath* p = [UIBezierPath bezierPathWithArcCenter:CGPointMake(sP.x, sP.y) radius:sR startAngle:0 endAngle:DEGREES_TO_RADIANS(360) clockwise:YES];
[drawColor setStroke];
[p stroke];
}
@end
#pragma mark -
#pragma mark -
@interface BezierViewForPointSmallArc(){
//三个分割点
CGPoint sP;
float sR;
//颜色
UIColor *drawColor;
}
@end
@implementation BezierViewForPointSmallArc
-(instancetype)initWithFrame:(CGRect)frameRect P:(CGPoint)P R:(float)R color:(UIColor*)color
{
if (self==[super initWithFrame:frameRect]) {
self.backgroundColor = [UIColor clearColor];
sP = P;
sR = R;
drawColor = color;
}
return self;
}
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
[drawColor set];
CGContextAddArc(context, sP.x, sP.y, sR, 0, 2*M_PI, 1);
CGContextDrawPath(context, kCGPathFillStroke);
//用UIBezierPath 默认已经获取上下文
//UIBezierPath* p = [UIBezierPath bezierPathWithArcCenter:CGPointMake(x, y) radius:b_line startAngle:0 endAngle:DEGREES_TO_RADIANS(360) clockwise:YES];
//
// [colorAry[i] setStroke];
// [p stroke];
}
@end