H文件atom
@property (nonatomic, strong) UISwipeGestureRecognizer *leftSwipeGestureRecognizer;spa
@property (nonatomic, strong) UISwipeGestureRecognizer *rightSwipeGestureRecognizer;3d
M文件code
self.leftSwipeGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipes:)];orm
self.rightSwipeGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipes:)];ip
self.leftSwipeGestureRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;get
self.rightSwipeGestureRecognizer.direction = UISwipeGestureRecognizerDirectionRight;it
[self.view addGestureRecognizer:self.leftSwipeGestureRecognizer];io
[self.view addGestureRecognizer:self.rightSwipeGestureRecognizer];class
- (void)handleSwipes:(UISwipeGestureRecognizer *)sender {
if (sender.direction == UISwipeGestureRecognizerDirectionLeft) {
_quartz.backgroundColor = [UIColor whiteColor];
}
if (sender.direction == UISwipeGestureRecognizerDirectionRight) {
_quartz.backgroundColor = [UIColor redColor];
}
}