Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @implementation ViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view, typically from a nib.
- elapsed = 0;
- numOfSpeed = 120;
- UIButton *playBtn = [[UIButton alloc] initWithFrame:CGRectMake(200, 200, 50, 50)];
- [playBtn setTitle:@"Play" forState:UIControlStateNormal];
- playBtn.backgroundColor = UIColor.redColor;
- [playBtn addTarget:self action:@selector(playButton:) forControlEvents:UIControlEventTouchUpInside];
- [self.view addSubview:playBtn];
- UIButton *incrementBtn = [[UIButton alloc] initWithFrame:CGRectMake(250, 200, 50, 50)];
- [incrementBtn setTitle:@"+" forState:UIControlStateNormal];
- incrementBtn.backgroundColor = UIColor.redColor;
- [incrementBtn addTarget:self action:@selector(incrementButton:) forControlEvents:UIControlEventTouchUpInside];
- [self.view addSubview:incrementBtn];
- UIButton *decrementBtn = [[UIButton alloc] initWithFrame:CGRectMake(150, 200, 50, 50)];
- [decrementBtn setTitle:@"-" forState:UIControlStateNormal];
- decrementBtn.backgroundColor = UIColor.redColor;
- [decrementBtn addTarget:self action:@selector(decrementButton:) forControlEvents:UIControlEventTouchUpInside];
- [self.view addSubview:decrementBtn ];
- self.label = [[UILabel alloc] initWithFrame:CGRectMake(200, 300, 100, 100)];
- self.label.text = [NSString stringWithFormat:@"%.0f", numOfSpeed];
- self.label.backgroundColor = UIColor.blueColor;
- [self.view addSubview:_label];
- [self configureSwipeRecognizerWithDirection:UISwipeGestureRecognizerDirectionUp];
- [self configureSwipeRecognizerWithDirection:UISwipeGestureRecognizerDirectionDown];
- [self configureSwipeRecognizerWithDirection:UISwipeGestureRecognizerDirectionLeft];
- [self configureSwipeRecognizerWithDirection:UISwipeGestureRecognizerDirectionRight];
- }
- - (void)configureSwipeRecognizerWithDirection:(UISwipeGestureRecognizerDirection)direction {
- UISwipeGestureRecognizer * recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeToControlTheSpeedOfRhythm:)];
- recognizer.direction = direction;
- recognizer.numberOfTouchesRequired = 1;
- [self.view addGestureRecognizer:recognizer];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement