Guest User

Untitled

a guest
Jun 19th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. - (void) drawTime : (float) hour min : (float) min {
  2. CGContextRef context = UIGraphicsGetCurrentContext();
  3. CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor);
  4.  
  5.  
  6. // min hand
  7. float mAngle = (90 - 6*min)*PI / 180;
  8. float mX = XC + M_LEN * cos(mAngle);
  9. float mY = MARGIN + RADIUS - M_LEN * sin(mAngle);
  10.  
  11. MOVE_TO_CTR();
  12. CGContextAddLineToPoint(context,mX, mY);
  13. CGContextStrokePath(context);
  14. CGContextAddEllipseInRect(context, CGRectMake(mX-5,mY-5, 10, 10));
  15. CGContextDrawPath(context, kCGPathFillStroke);
  16.  
  17. // Hour hand
  18. float hAngle = (90 - 30*hour)*PI / 180;
  19. float hX = XC + H_LEN * cos(hAngle);
  20. float hY = MARGIN + RADIUS - H_LEN * sin(hAngle);
  21.  
  22. MOVE_TO_CTR();
  23. CGContextAddLineToPoint(context,hX, hY);
  24. CGContextStrokePath(context);
  25. CGContextAddEllipseInRect(context, CGRectMake(hX-5,hY-5, 10, 10));
  26. CGContextDrawPath(context, kCGPathFillStroke);
  27.  
  28. }
Add Comment
Please, Sign In to add comment