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];
- UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeToControlTheSpeedOfRhythm:)];
- UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeToControlTheSpeedOfRhythm:)];
- UISwipeGestureRecognizer *swipeUp = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeToControlTheSpeedOfRhythm:)];
- UISwipeGestureRecognizer *swipeDown = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeToControlTheSpeedOfRhythm:)];
- [swipeRight setDirection:UISwipeGestureRecognizerDirectionRight];
- [swipeLeft setDirection:UISwipeGestureRecognizerDirectionLeft];
- [swipeUp setDirection:UISwipeGestureRecognizerDirectionUp];
- [swipeDown setDirection:UISwipeGestureRecognizerDirectionDown];
- [swipeLeft setNumberOfTouchesRequired:1];
- [swipeRight setNumberOfTouchesRequired:1];
- [swipeUp setNumberOfTouchesRequired:1];
- [swipeDown setNumberOfTouchesRequired:1];
- [self.view addGestureRecognizer:swipeLeft];
- [self.view addGestureRecognizer:swipeUp];
- [self.view addGestureRecognizer:swipeDown];
- [self.view addGestureRecognizer:swipeRight];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement