Guest User

Untitled

a guest
Jul 18th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //// General Declarations
  2. CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
  3. CGContextRef context = UIGraphicsGetCurrentContext();
  4.  
  5. //// Color Declarations
  6. UIColor* offWhite = [UIColor colorWithRed: 0.95 green: 0.95 blue: 0.95 alpha: 1];
  7. UIColor* red1 = [UIColor colorWithRed: 0.71 green: 0 blue: 0 alpha: 1];
  8. UIColor* red2 = [UIColor colorWithRed: 0.86 green: 0 blue: 0 alpha: 1];
  9.  
  10. //// Gradient Declarations
  11. NSArray* gradientColors = [NSArray arrayWithObjects:
  12.     (id)[UIColor whiteColor].CGColor,
  13.     (id)offWhite.CGColor, nil];
  14. CGFloat gradientLocations[] = {0, 1};
  15. CGGradientRef gradient = CGGradientCreateWithColors(colorSpace, (CFArrayRef)gradientColors, gradientLocations);
  16. NSArray* gradient2Colors = [NSArray arrayWithObjects:
  17.     (id)red1.CGColor,
  18.     (id)red2.CGColor, nil];
  19. CGFloat gradient2Locations[] = {0, 1};
  20. CGGradientRef gradient2 = CGGradientCreateWithColors(colorSpace, (CFArrayRef)gradient2Colors, gradient2Locations);
  21.  
  22. //// Shadow Declarations
  23. CGColorRef shadow = [UIColor blackColor].CGColor;
  24. CGSize shadowOffset = CGSizeMake(0, -0);
  25. CGFloat shadowBlurRadius = 3;
  26.  
  27.  
  28. //// Oval Drawing
  29. UIBezierPath* ovalPath = [UIBezierPath bezierPathWithOvalInRect: CGRectMake(50, 50, 100, 100)];
  30. CGContextSaveGState(context);
  31. CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow);
  32. CGContextSetFillColorWithColor(context, shadow);
  33. [ovalPath fill];
  34. [ovalPath addClip];
  35. CGContextDrawRadialGradient(context, gradient,
  36.     CGPointMake(100, 100), 10,
  37.     CGPointMake(100, 100), 30,
  38.     kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation);
  39. CGContextRestoreGState(context);
  40.  
  41. [[UIColor blackColor] setStroke];
  42. ovalPath.lineWidth = 1;
  43. [ovalPath stroke];
  44.  
  45.  
  46. //// Tick Drawing
  47. UIBezierPath* tickPath = [UIBezierPath bezierPathWithRect: CGRectMake(99.5, 54.5, 2, 9)];
  48. [[UIColor darkGrayColor] setFill];
  49. [tickPath fill];
  50.  
  51.  
  52.  
  53. //// Hand Drawing
  54. UIBezierPath* handPath = [UIBezierPath bezierPath];
  55. [handPath moveToPoint: CGPointMake(99.5, 100.5)];
  56. [handPath addLineToPoint: CGPointMake(101.14, 100.5)];
  57. [handPath addCurveToPoint: CGPointMake(102.51, 100.5) controlPoint1: CGPointMake(101.14, 100.5) controlPoint2: CGPointMake(102.41, 100.5)];
  58. [handPath addCurveToPoint: CGPointMake(101.14, 54) controlPoint1: CGPointMake(102.61, 100.5) controlPoint2: CGPointMake(101.14, 54.01)];
  59. [handPath addCurveToPoint: CGPointMake(99.5, 100.5) controlPoint1: CGPointMake(101.14, 53.99) controlPoint2: CGPointMake(99.5, 100.5)];
  60. [handPath closePath];
  61. CGContextSaveGState(context);
  62. [handPath addClip];
  63. CGContextDrawLinearGradient(context, gradient2, CGPointMake(101.01, 100.5), CGPointMake(101.01, 54), 0);
  64. CGContextRestoreGState(context);
  65.  
  66.  
  67. //// Cleanup
  68. CGGradientRelease(gradient);
  69. CGGradientRelease(gradient2);
  70. CGColorSpaceRelease(colorSpace);
Add Comment
Please, Sign In to add comment