|
@@ -126,13 +126,9 @@
|
|
|
{
|
|
|
CGContextSetStrokeColorWithColor(context, self.fillColor.CGColor);
|
|
|
CGContextSetFillColorWithColor(context, self.fillShapeColor.CGColor);
|
|
|
- if (self.thickness) {
|
|
|
- CGContextSetLineWidth(context, self.thickness);
|
|
|
- } else {
|
|
|
- CGFloat dashLengths[2] = {6, 2};
|
|
|
- CGContextSetLineDash(context, 0, dashLengths, 2);
|
|
|
- CGContextSetLineWidth(context, self.dotted);
|
|
|
- }
|
|
|
+ CGFloat dashLengths[2] = {6, self.dotted};
|
|
|
+ CGContextSetLineDash(context, 0, dashLengths, 2);
|
|
|
+ CGContextSetLineWidth(context, self.thickness);
|
|
|
CGContextAddArc(context, CGRectGetMaxX(self.bounds)/2, CGRectGetMaxY(self.bounds)/2, 30, 0, 2*PI, 0);
|
|
|
CGContextDrawPath(context, kCGPathStroke);
|
|
|
CGContextAddArc(context, CGRectGetMaxX(self.bounds)/2, CGRectGetMaxY(self.bounds)/2, 30, 0, 2*PI, 0);
|
|
@@ -143,13 +139,9 @@
|
|
|
{
|
|
|
CGContextSetStrokeColorWithColor(context, self.fillColor.CGColor);
|
|
|
CGContextSetFillColorWithColor(context, self.fillShapeColor.CGColor);
|
|
|
- if (self.thickness) {
|
|
|
- CGContextSetLineWidth(context, self.thickness);
|
|
|
- } else {
|
|
|
- CGFloat dashLengths[2] = {6, 2};
|
|
|
- CGContextSetLineDash(context, 0, dashLengths, 2);
|
|
|
- CGContextSetLineWidth(context, self.dotted);
|
|
|
- }
|
|
|
+ CGFloat dashLengths[2] = {6, self.dotted};
|
|
|
+ CGContextSetLineDash(context, 0, dashLengths, 2);
|
|
|
+ CGContextSetLineWidth(context, self.thickness);
|
|
|
CGContextStrokeRect(context, self.centerRect);
|
|
|
CGContextFillRect(context, self.centerRect);
|
|
|
}
|
|
@@ -157,21 +149,118 @@
|
|
|
case CPDFSamplesShapeArrow:
|
|
|
{
|
|
|
CGContextSetStrokeColorWithColor(context, self.fillColor.CGColor);
|
|
|
- if (self.thickness) {
|
|
|
- CGContextSetLineWidth(context, self.thickness);
|
|
|
- } else {
|
|
|
- CGFloat dashLengths[2] = {6, 2};
|
|
|
- CGContextSetLineDash(context, 0, dashLengths, 2);
|
|
|
- CGContextSetLineWidth(context, self.dotted);
|
|
|
+ CGContextSetFillColorWithColor(context, self.fillColor.CGColor);
|
|
|
+ CGFloat dashLengths[2] = {6, self.dotted};
|
|
|
+ CGContextSetLineDash(context, 0, dashLengths, 2);
|
|
|
+ CGContextSetLineWidth(context, self.thickness);
|
|
|
+
|
|
|
+ CGPoint start = CGPointMake(CGRectGetMinX(self.arrowRect), CGRectGetMaxY(self.arrowRect));
|
|
|
+ CGPoint end = CGPointMake(CGRectGetMaxX(self.arrowRect), CGRectGetMinY(self.arrowRect));
|
|
|
+ [self drawArrow:context startPoint:start endPoint:end];
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case CPDFSamplesShapeLine:
|
|
|
+ {
|
|
|
+ CGContextSetStrokeColorWithColor(context, self.fillColor.CGColor);
|
|
|
+ CGContextSetFillColorWithColor(context, self.fillColor.CGColor);
|
|
|
+ CGFloat dashLengths[2] = {6, self.dotted};
|
|
|
+ CGContextSetLineDash(context, 0, dashLengths, 2);
|
|
|
+ CGContextSetLineWidth(context, self.thickness);
|
|
|
+
|
|
|
+ CGPoint start = CGPointMake(CGRectGetMinX(self.arrowRect), CGRectGetMaxY(self.arrowRect));
|
|
|
+ CGPoint end = CGPointMake(CGRectGetMaxX(self.arrowRect), CGRectGetMinY(self.arrowRect));
|
|
|
+ [self drawArrow:context startPoint:start endPoint:end];
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case CPDFSamplesFreeText:
|
|
|
+ {
|
|
|
+ NSString *sampleStr = @"AaBbCc";
|
|
|
+ CGContextSetAlpha(context, self.opcity);
|
|
|
+ UIFont *font = [UIFont fontWithName:self.fontName size:self.thickness];
|
|
|
+ NSMutableDictionary *dic = [NSMutableDictionary dictionary];
|
|
|
+ if (self.isBold && !(self.isUnderline)) {
|
|
|
+ font = [UIFont boldSystemFontOfSize:self.thickness];
|
|
|
+ } else if (self.isUnderline && !(self.isBold)) {
|
|
|
+ [dic addEntriesFromDictionary:@{NSFontAttributeName:font, NSUnderlineStyleAttributeName:@1}];
|
|
|
+ } else if (self.isBold && self.isUnderline) {
|
|
|
+ font = [UIFont boldSystemFontOfSize:self.thickness];
|
|
|
+ [dic addEntriesFromDictionary:@{NSFontAttributeName:font, NSUnderlineStyleAttributeName:@1}];
|
|
|
}
|
|
|
- CGContextMoveToPoint(context, CGRectGetMinX(self.arrowRect), CGRectGetMaxY(self.arrowRect));
|
|
|
- CGContextAddLineToPoint(context, CGRectGetMaxX(self.arrowRect), CGRectGetMinY(self.arrowRect));
|
|
|
+ [dic addEntriesFromDictionary:@{NSFontAttributeName:font, NSForegroundColorAttributeName:self.fillColor}];
|
|
|
+ [sampleStr drawInRect:self.arrowRect withAttributes:dic];
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)drawArrow:(CGContextRef)context startPoint:(CGPoint)start endPoint:(CGPoint)end {
|
|
|
+ switch (self.arrowStyleIndex) {
|
|
|
+ case 0:
|
|
|
+ {
|
|
|
+ CGContextMoveToPoint(context, start.x, start.y);
|
|
|
+ CGContextAddLineToPoint(context, end.x, end.y);
|
|
|
+ CGContextStrokePath(context);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ {
|
|
|
+ CGContextMoveToPoint(context, start.x, start.y);
|
|
|
+ CGContextAddLineToPoint(context, end.x, end.y);
|
|
|
+
|
|
|
+ CGContextMoveToPoint(context, end.x-20, end.y);
|
|
|
+ CGContextAddLineToPoint(context, end.x, end.y);
|
|
|
+ CGContextAddLineToPoint(context, end.x, end.y+20);
|
|
|
+ CGContextStrokePath(context);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ {
|
|
|
+ CGContextMoveToPoint(context, start.x, start.y);
|
|
|
+ CGContextAddLineToPoint(context, end.x, end.y);
|
|
|
+ CGContextStrokePath(context);
|
|
|
+
|
|
|
+ CGContextMoveToPoint(context, end.x-7.5, end.y-7.5);
|
|
|
+ CGContextAddLineToPoint(context, end.x+15, end.y-15);
|
|
|
+ CGContextAddLineToPoint(context, end.x+7.5, end.y+7.5);
|
|
|
+ CGContextFillPath(context);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ {
|
|
|
+ CGContextMoveToPoint(context, start.x, start.y);
|
|
|
+ CGContextAddLineToPoint(context, end.x, end.y);
|
|
|
+ CGContextStrokePath(context);
|
|
|
|
|
|
- CGContextMoveToPoint(context, CGRectGetMaxX(self.arrowRect) - 20, CGRectGetMinY(self.arrowRect));
|
|
|
- CGContextAddLineToPoint(context, CGRectGetMaxX(self.arrowRect), CGRectGetMinY(self.arrowRect));
|
|
|
- CGContextAddLineToPoint(context, CGRectGetMaxX(self.arrowRect), CGRectGetMinY(self.arrowRect) + 20);
|
|
|
+ CGContextMoveToPoint(context, end.x-7.5, end.y-7.5);
|
|
|
+ CGContextAddLineToPoint(context, end.x+7.5, end.y+7.5);
|
|
|
+ CGContextAddLineToPoint(context, end.x+22.5, end.y-7.5);
|
|
|
+ CGContextAddLineToPoint(context, end.x+7.5, end.y-22.5);
|
|
|
+ CGContextFillPath(context);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ {
|
|
|
+ CGContextMoveToPoint(context, start.x, start.y);
|
|
|
+ CGContextAddLineToPoint(context, end.x, end.y);
|
|
|
+ CGContextStrokePath(context);
|
|
|
|
|
|
+ CGContextAddArc(context, end.x+7.5, end.y-7.5, 10, 0, 2*3.14159265358979323846, 0);
|
|
|
+ CGContextDrawPath(context, kCGPathStroke);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 5:
|
|
|
+ {
|
|
|
+ CGContextMoveToPoint(context, start.x, start.y);
|
|
|
+ CGContextAddLineToPoint(context, end.x, end.y);
|
|
|
CGContextStrokePath(context);
|
|
|
+
|
|
|
+ CGContextMoveToPoint(context, end.x, end.y);
|
|
|
+ CGContextAddLineToPoint(context, end.x+15, end.y);
|
|
|
+ CGContextAddLineToPoint(context, end.x+15, end.y-15);
|
|
|
+ CGContextAddLineToPoint(context, end.x, end.y-15);
|
|
|
+ CGContextFillPath(context);
|
|
|
}
|
|
|
break;
|
|
|
default:
|