Advertisement
redribben

drawinrect

Jun 4th, 2015
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #import "ButtonView.h"
  2.  
  3. @implementation ButtonView
  4.  
  5. - (void)drawRect:(CGRect)rect
  6. {
  7.     //// General Declarations
  8.     CGContextRef context = UIGraphicsGetCurrentContext();
  9.    
  10.     //// Color Declarations
  11.     UIColor* color4 = [UIColor colorWithRed: 0.293 green: 0.69 blue: 0.256 alpha: 1];
  12.    
  13.     //// playButton
  14.     {
  15.         CGContextSaveGState(context);
  16.         CGContextSetAlpha(context, 0.9);
  17.         CGContextBeginTransparencyLayer(context, NULL);
  18.        
  19.        
  20.         //// circleOutline Drawing
  21.         UIBezierPath* circleOutlinePath = UIBezierPath.bezierPath;
  22.         [circleOutlinePath moveToPoint: CGPointMake(165.83, 165.69)];
  23.         [circleOutlinePath addCurveToPoint: CGPointMake(165.83, 33.81) controlPoint1: CGPointMake(202.06, 129.27) controlPoint2: CGPointMake(202.06, 70.23)];
  24.         [circleOutlinePath addCurveToPoint: CGPointMake(34.67, 33.81) controlPoint1: CGPointMake(129.61, -2.6) controlPoint2: CGPointMake(70.89, -2.6)];
  25.         [circleOutlinePath addCurveToPoint: CGPointMake(34.67, 165.69) controlPoint1: CGPointMake(-1.56, 70.23) controlPoint2: CGPointMake(-1.56, 129.27)];
  26.         [circleOutlinePath addCurveToPoint: CGPointMake(165.83, 165.69) controlPoint1: CGPointMake(70.89, 202.1) controlPoint2: CGPointMake(129.61, 202.1)];
  27.         [circleOutlinePath closePath];
  28.         [color4 setStroke];
  29.         circleOutlinePath.lineWidth = 5.5;
  30.         [circleOutlinePath stroke];
  31.  
  32.        
  33.        
  34.         //// Triangle Drawing
  35.         UIBezierPath* trianglePath = UIBezierPath.bezierPath;
  36.         [trianglePath moveToPoint: CGPointMake(64.5, 40.5)];
  37.         [trianglePath addLineToPoint: CGPointMake(164.5, 99.5)];
  38.         [trianglePath addLineToPoint: CGPointMake(64.5, 158.5)];
  39.         [trianglePath addLineToPoint: CGPointMake(64.5, 99.5)];
  40.         [trianglePath addLineToPoint: CGPointMake(64.5, 40.5)];
  41.         [trianglePath addLineToPoint: CGPointMake(64.5, 40.5)];
  42.         [trianglePath closePath];
  43.         trianglePath.lineCapStyle = kCGLineCapRound;
  44.        
  45.         [color4 setFill];
  46.         [trianglePath fill];
  47.         [color4 setStroke];
  48.         trianglePath.lineWidth = 1;
  49.         [trianglePath stroke];
  50.        
  51.        
  52.        
  53. //        // This assumes the clippingPath and image are in the same coordinate space, and scales both to fill the view bounds.
  54. //        if ([self image])
  55. //        {
  56. //            CGSize imageSize = [[self image] size];
  57. //            CGRect bounds = [self bounds];
  58. //            
  59. //            CGContextRef context = UIGraphicsGetCurrentContext();
  60. //            CGContextScaleCTM(context, bounds.size.width/imageSize.width, bounds.size.height/imageSize.height);
  61. //        
  62. //        // This assumes the clippingPath and image may be drawn in the current coordinate space.
  63. //        [[self clippingPath] addClip];
  64. //        [[self image] drawAtPoint:CGPointZero];
  65.        
  66.         CGContextEndTransparencyLayer(context);
  67.         CGContextRestoreGState(context);
  68.     }
  69. }
  70. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement