Guest User

Untitled

a guest
Jul 20th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. @implementation MMTouchSlider
  2.  
  3. -(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
  4.  
  5. UITouch *touch = [[event allTouches] anyObject];
  6. CGPoint touchLocation = [touch locationInView:self];
  7.  
  8. self.value = self.minimumValue + (self.maximumValue - self.minimumValue) * (touchLocation.x / self.frame.size.width);
  9.  
  10. [super touchesBegan:touches withEvent:event];
  11. }
  12.  
  13. - (CGRect)thumbRectForBounds:(CGRect)bounds trackRect:(CGRect)rect value:(float)value {
  14.  
  15. CGRect thumbRect = [super thumbRectForBounds:bounds trackRect:rect value:value];
  16. return thumbRect;
  17. }
  18.  
  19. @end
  20.  
  21. UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(100, 100, 200, 10)];
  22. float angleInDegrees = 270;
  23. float angleInRadians = angleInDegrees * (M_PI/180);
  24. slider.transform = CGAffineTransformMakeRotation(angleInRadians);
  25. [self.view addSubView:slider];
Add Comment
Please, Sign In to add comment