#import "loginSuccessViewController.h"
@interface loginSuccessViewController ()
{
UIButton *_ljBackButton;
}
@end
@implementation loginSuccessViewController
- (void)viewDidLoad
{
[super viewDidLoad];
_ljBackButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_ljBackButton setFrame:CGRectMake(100, 200, 100, 44)];
[_ljBackButton setBackgroundColor:[UIColor grayColor]];
//[_ljBackButton addTarget:self action:@selector(backButtonClick) forControlEvents:UIControlEventTouchUpInside];
[_ljBackButton setTitle:@"测试" forState:UIControlStateNormal];
[_ljBackButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
[self.view addSubview:_ljBackButton];
// 添加右滑移除手势
UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeToDirection:)];
swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
[_ljBackButton addGestureRecognizer:swipeRight];
// 添加右滑移除手势
UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeToDirection:)];
swipeRight.direction = UISwipeGestureRecognizerDirectionLeft;
[_ljBackButton addGestureRecognizer:swipeLeft];
}
- (void)swipeToDirection:(UISwipeGestureRecognizer *)swipeGesture
{
if (swipeGesture.direction == UISwipeGestureRecognizerDirectionRight)
{
// 向右滑动
NSLog(@"-----DirectionRight");
[_ljBackButton setHidden:YES];
}
else if (swipeGesture.direction == UISwipeGestureRecognizerDirectionLeft)
{
// 向左滑动
NSLog(@"-----DirectionLeft");
[_ljBackButton setHidden:YES];
}
}
@end