Skip to content

Instantly share code, notes, and snippets.

@jscalo
Created September 26, 2014 21:31
Show Gist options
  • Save jscalo/746f896d6562bcc60260 to your computer and use it in GitHub Desktop.
Save jscalo/746f896d6562bcc60260 to your computer and use it in GitHub Desktop.
// E.g. usage
UIButton *shareButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 39, 56)];
[shareButton addTarget:self action:@selector(share:) forControlEvents:UIControlEventTouchUpInside];
[shareButton setImage:[PaintCodeStyleKit imageOfShareWithTextWithTintColor:[UIColor whiteColor]] forState:UIControlStateNormal];
+ (UIImage*)imageOfShareWithTextWithTintColor: (UIColor*)tintColor;
{
UIGraphicsBeginImageContextWithOptions(CGSizeMake(31, 36), NO, 0.0f);
[PaintCodeStyleKit drawShareWithTextWithTintColor: tintColor];
UIImage* imageOfShareWithText = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return imageOfShareWithText;
}
+ (void)drawShareWithTextWithTintColor: (UIColor*)tintColor;
{
//// Text Drawing
CGRect textRect = CGRectMake(-2, 23, 35, 14);
NSMutableParagraphStyle* textStyle = NSMutableParagraphStyle.defaultParagraphStyle.mutableCopy;
textStyle.alignment = NSTextAlignmentCenter;
NSDictionary* textFontAttributes = @{NSFontAttributeName: [UIFont fontWithName: @"AvenirNextCondensed-Bold" size: UIFont.smallSystemFontSize], NSForegroundColorAttributeName: tintColor, NSParagraphStyleAttributeName: textStyle};
[@"SHARE" drawInRect: textRect withAttributes: textFontAttributes];
//// Box Drawing
UIBezierPath* boxPath = UIBezierPath.bezierPath;
[boxPath moveToPoint: CGPointMake(18.5, 10)];
[boxPath addLineToPoint: CGPointMake(23, 10)];
[boxPath addLineToPoint: CGPointMake(23, 23.5)];
[boxPath addLineToPoint: CGPointMake(8, 23.5)];
[boxPath addLineToPoint: CGPointMake(8, 10)];
[boxPath addLineToPoint: CGPointMake(12.5, 10)];
[tintColor setStroke];
boxPath.lineWidth = 2;
[boxPath stroke];
//// Arrow Top Drawing
UIBezierPath* arrowTopPath = UIBezierPath.bezierPath;
[arrowTopPath moveToPoint: CGPointMake(11.5, 5)];
[arrowTopPath addLineToPoint: CGPointMake(15.5, 1.5)];
[arrowTopPath addLineToPoint: CGPointMake(19.5, 5)];
[tintColor setStroke];
arrowTopPath.lineWidth = 2;
[arrowTopPath stroke];
//// Arrow Line Drawing
UIBezierPath* arrowLinePath = UIBezierPath.bezierPath;
[arrowLinePath moveToPoint: CGPointMake(15.5, 2.5)];
[arrowLinePath addLineToPoint: CGPointMake(15.5, 16.5)];
[tintColor setStroke];
arrowLinePath.lineWidth = 2;
[arrowLinePath stroke];
}
@jscalo
Copy link
Author

jscalo commented Sep 26, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment