Advertisement
Guest User

Untitled

a guest
Mar 11th, 2015
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. @implementation ViewController
  2.  
  3. - (void)viewDidLoad {
  4. [super viewDidLoad];
  5. // Do any additional setup after loading the view, typically from a nib.
  6.  
  7. elapsed = 0;
  8. numOfSpeed = 120;
  9.  
  10. UIButton *playBtn = [[UIButton alloc] initWithFrame:CGRectMake(200, 200, 50, 50)];
  11. [playBtn setTitle:@"Play" forState:UIControlStateNormal];
  12. playBtn.backgroundColor = UIColor.redColor;
  13. [playBtn addTarget:self action:@selector(playButton:) forControlEvents:UIControlEventTouchUpInside];
  14. [self.view addSubview:playBtn];
  15.  
  16. UIButton *incrementBtn = [[UIButton alloc] initWithFrame:CGRectMake(250, 200, 50, 50)];
  17. [incrementBtn setTitle:@"+" forState:UIControlStateNormal];
  18. incrementBtn.backgroundColor = UIColor.redColor;
  19. [incrementBtn addTarget:self action:@selector(incrementButton:) forControlEvents:UIControlEventTouchUpInside];
  20. [self.view addSubview:incrementBtn];
  21.  
  22. UIButton *decrementBtn = [[UIButton alloc] initWithFrame:CGRectMake(150, 200, 50, 50)];
  23. [decrementBtn setTitle:@"-" forState:UIControlStateNormal];
  24. decrementBtn.backgroundColor = UIColor.redColor;
  25. [decrementBtn addTarget:self action:@selector(decrementButton:) forControlEvents:UIControlEventTouchUpInside];
  26. [self.view addSubview:decrementBtn ];
  27.  
  28. self.label = [[UILabel alloc] initWithFrame:CGRectMake(200, 300, 100, 100)];
  29. self.label.text = [NSString stringWithFormat:@"%.0f", numOfSpeed];
  30. self.label.backgroundColor = UIColor.blueColor;
  31. [self.view addSubview:_label];
  32.  
  33.  
  34. UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeToControlTheSpeedOfRhythm:)];
  35. UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeToControlTheSpeedOfRhythm:)];
  36. UISwipeGestureRecognizer *swipeUp = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeToControlTheSpeedOfRhythm:)];
  37. UISwipeGestureRecognizer *swipeDown = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeToControlTheSpeedOfRhythm:)];
  38. [swipeRight setDirection:UISwipeGestureRecognizerDirectionRight];
  39. [swipeLeft setDirection:UISwipeGestureRecognizerDirectionLeft];
  40. [swipeUp setDirection:UISwipeGestureRecognizerDirectionUp];
  41. [swipeDown setDirection:UISwipeGestureRecognizerDirectionDown];
  42. [swipeLeft setNumberOfTouchesRequired:1];
  43. [swipeRight setNumberOfTouchesRequired:1];
  44. [swipeUp setNumberOfTouchesRequired:1];
  45. [swipeDown setNumberOfTouchesRequired:1];
  46. [self.view addGestureRecognizer:swipeLeft];
  47. [self.view addGestureRecognizer:swipeUp];
  48. [self.view addGestureRecognizer:swipeDown];
  49. [self.view addGestureRecognizer:swipeRight];
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement