IOS开发之代码注释的滑动效果

来源:爱站网时间:2021-02-09编辑:网友分享
随着移动互联网的高效发展,苹果手机也要不断的更新,才能满足用户的需求,而最简单的滑动功能也要进行升级,本文是爱站技术频道小编为大家整理的IOS开发之代码注释的滑动效果,一起进入下文参考看看吧!

随着移动互联网的高效发展,苹果手机也要不断的更新,才能满足用户的需求,而最简单的滑动功能也要进行升级,本文是爱站技术频道小编为大家整理的IOS开发之代码注释的滑动效果,一起进入下文参考看看吧!

一、效果图

 

二、代码
RootViewController.m

 - (void)viewDidLoad
{
  [super viewDidLoad];
  // Do any additional setup after loading the view.
  
  self.title=@"可以向左(右)滑动";
  
  //向右滑动
  UISwipeGestureRecognizer *recognizerLeft;
  recognizerLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFromLeft:)];
  [recognizerLeft setDirection:(UISwipeGestureRecognizerDirectionLeft)];
  [self.view addGestureRecognizer:recognizerLeft];
  
  //向左滑动
  UISwipeGestureRecognizer *recognizerRight;
  recognizerRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFromRight:)];
  [recognizerRight setDirection:(UISwipeGestureRecognizerDirectionRight)];
  [self.view addGestureRecognizer:recognizerRight];

}
#pragma -mark -手势滑动
//向左滑动
-(void)handleSwipeFromLeft:(UISwipeGestureRecognizer *)recognizer {
  
  NSLog(@"-------进入向左手势滑动姿势-------------");
  if (recognizer.direction==UISwipeGestureRecognizerDirectionLeft) {
    
    UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提醒" message:@"进入向左手势滑动姿势" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
    [alert show];
    
    
  }
}
//向右滑动
-(void)handleSwipeFromRight:(UISwipeGestureRecognizer *)recognizer {
  
  NSLog(@"-------进入向右手势滑动姿势-------------");
  if (recognizer.direction==UISwipeGestureRecognizerDirectionRight) {
    
    UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提醒" message:@"进入向右手势滑动姿势" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
    [alert show];
    
  }
}

IOS开发之代码注释的滑动效果,大家是不是都认真地记住了?如果大家还想要学习到更多的专业知识,就继续关注爱站技术频道吧!

上一篇:IOS开发中代码注释的下拉效果

下一篇:IOS开发中内存的管理规则

您可能感兴趣的文章

相关阅读

热门软件源码

最新软件源码下载