ios UISwipeGestureRecognizer 左右滑动隐藏按钮
程序员文章站
2022-04-18 11:31:55
...
#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
推荐阅读
-
如何在Android中实现渐显按钮的左右滑动效果
-
使用jQuery实现鼠标点击左右按钮滑动切换
-
jQuery图片切换显示隐藏左右按钮控制图片-20130626
-
jQuery图片切换显示隐藏左右按钮控制图片-20130626
-
调整swiper中的左右滑动按钮位置
-
在窗口中设置三个“圆形”“扇形”“矩形”按钮,点击按钮,将图形变为相应的形状(实心),设置三个“红色”“绿色”“蓝色”滚动条,滑动滚动条变换图形的颜色,设置一个控制左右移动的滚动条,点击滚动条变换图形
-
Unity UGUI 按钮呈半圆型滑动的无限列表 可左右镜像排列
-
使用jQuery实现鼠标点击左右按钮滑动切换
-
ios UISwipeGestureRecognizer 左右滑动隐藏按钮
-
css div内容左右滑动隐藏滚动条