Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- + (UIBezierPath *) trianglePathWithSize: (CGSize) size;
- {
- CGContextRef context = UIGraphicsGetCurrentContext();
- CGContextSaveGState(context);
- CGContextSetAlpha(context, 0.9);
- CGContextBeginTransparencyLayer(context, NULL);
- UIBezierPath *circleOutlinePath = [UIBezierPath bezierPath];
- circleOutlinePath.lineJoinStyle = kCGLineJoinMiter;
- [circleOutlinePath moveToPoint: CGPointMake(165.83, 165.69)];
- [circleOutlinePath addCurveToPoint: CGPointMake(165.83, 33.81) controlPoint1: CGPointMake(202.06, 129.27) controlPoint2: CGPointMake(202.06, 70.23)];
- [circleOutlinePath addCurveToPoint: CGPointMake(34.67, 33.81) controlPoint1: CGPointMake(129.61, -2.6) controlPoint2: CGPointMake(70.89, -2.6)];
- [circleOutlinePath addCurveToPoint: CGPointMake(34.67, 165.69) controlPoint1: CGPointMake(-1.56, 70.23) controlPoint2: CGPointMake(-1.56, 129.27)];
- [circleOutlinePath addCurveToPoint: CGPointMake(165.83, 165.69) controlPoint1: CGPointMake(70.89, 202.1) controlPoint2: CGPointMake(129.61, 202.1)];
- [circleOutlinePath closePath];
- CGContextEndTransparencyLayer(context);
- CGContextRestoreGState(context);
- return circleOutlinePath;
- }
- - (UIImage *) imageWithStrokeColor: (UIColor *) strokeColor fillColor: (UIColor *)
- fillColor
- {
- CGRect bounds = self.bounds;
- UIGraphicsBeginImageContextWithOptions(CGSizeMake(bounds.size.width + self.lineWidth * 2, bounds.size.width + self.lineWidth * 2),
- false, [UIScreen mainScreen].scale);
- CGContextRef context = UIGraphicsGetCurrentContext();
- // offset the draw to allow the line thickness to not get clipped
- CGContextTranslateCTM(context, self.lineWidth, self.lineWidth);
- if (!strokeColor)
- {
- strokeColor = fillColor;
- }
- else
- if (!fillColor)
- {
- fillColor = strokeColor;
- }
- [strokeColor setStroke];
- [fillColor setFill];
- [self fill];
- [self stroke];
- UIImage *result = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment