Guest User

Untitled

a guest
Jun 25th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
  2. {
  3. UITouch *touch = [touches anyObject];
  4. firstTouch = [touch locationInView:self];
  5.  
  6. CGSize mySize = CGSizeMake(5, 5);
  7. UIGraphicsBeginImageContext(mySize);
  8. CGContextRef ctx = UIGraphicsGetCurrentContext();
  9.  
  10. CGContextBeginPath(ctx);
  11. CGContextSetRGBFillColor(ctx, 1, 0, 0, 1);
  12. CGContextAddRect(ctx, CGRectMake(0, 0, 5, 5));
  13. CGContextFillPath(ctx);
  14.  
  15. UIImage *redRect = UIGraphicsGetImageFromCurrentImageContext();
  16. UIGraphicsEndImageContext();
  17.  
  18. UIImageView *redRectView = [[UIImageView alloc] initWithImage:redRect];
  19. redRectView.center = CGPointMake(firstTouch.x, firstTouch.y);
  20. [self addSubview:redRectView];
  21.  
  22. }
Add Comment
Please, Sign In to add comment