欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

iOS實(shí)現(xiàn)翻頁(yè)效果動(dòng)畫(huà)實(shí)例代碼

 更新時(shí)間:2017年05月23日 10:44:31   作者:劉光軍_Shine  
本篇文章主要介紹了iOS實(shí)現(xiàn)翻頁(yè)效果動(dòng)畫(huà)實(shí)例代碼,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧

大體思路:

在self.view 上放置一個(gè)label,label.text從數(shù)組中獲得,當(dāng)點(diǎn)擊上下頁(yè)按鈕的時(shí)候,改變label.text,并且執(zhí)行翻頁(yè)效果動(dòng)畫(huà).

效果如圖:

主要代碼:

#pragma mark - 下一頁(yè)按鈕響應(yīng)事件
- (void)nextPage:(UIButton *)btn {
  _forwardBtn.enabled = YES;
  if (_count<_arr.count-1) {
    btn.enabled = YES;
    _label.text = [_arr objectAtIndex:_count+1];
    NSString *subtypeString;
    subtypeString = kCATransitionFromRight;
    [self transitionWithType:@"pageCurl" WithSubtype:subtypeString ForView:self.view];
    _count = _count + 1;
  } else {
    _count = _arr.count - 1;
    btn.enabled = NO;
    [self showAlert:@"已經(jīng)是最后一頁(yè)咯,親(づ ̄ 3 ̄)づ"];
  }
  NSLog(@"%ld", (long)_count);

}

#pragma CATransition動(dòng)畫(huà)實(shí)現(xiàn)
/**
 * 動(dòng)畫(huà)效果實(shí)現(xiàn)
 *
 * @param type  動(dòng)畫(huà)的類型 在開(kāi)頭的枚舉中有列舉,比如 CurlDown//下翻頁(yè),CurlUp//上翻頁(yè)
,FlipFromLeft//左翻轉(zhuǎn),FlipFromRight//右翻轉(zhuǎn) 等...
 * @param subtype 動(dòng)畫(huà)執(zhí)行的起始位置,上下左右
 * @param view  哪個(gè)view執(zhí)行的動(dòng)畫(huà)
 */
- (void) transitionWithType:(NSString *) type WithSubtype:(NSString *) subtype ForView : (UIView *) view {
  CATransition *animation = [CATransition animation];
  animation.duration = 0.7f;
  animation.type = type;
  if (subtype != nil) {
    animation.subtype = subtype;
  }
  animation.timingFunction = UIViewAnimationOptionCurveEaseInOut;
  [view.layer addAnimation:animation forKey:@"animation"];
}

主要就是熟悉一下簡(jiǎn)單動(dòng)畫(huà)的實(shí)現(xiàn)了

本項(xiàng)目gitHub地址:https://github.com/iOSJason/PageBlurDemo.git

2 添加啟動(dòng)頁(yè)和手勢(shì)控制的翻頁(yè)效果實(shí)現(xiàn),添加swipe手勢(shì)后畫(huà)面切換更生動(dòng).

效果圖:


#pragma mark - 手勢(shì)
- (void)configTapGes {
  _fromRightSwip = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(nextPage:)];
  _fromRightSwip.direction = UISwipeGestureRecognizerDirectionLeft;
  [self.view addGestureRecognizer:_fromRightSwip];

  _fromLeftSwip = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(forwardPage:)];
  _fromLeftSwip.direction = UISwipeGestureRecognizerDirectionRight;
  [self.view addGestureRecognizer:_fromLeftSwip];
}
//判斷是否是第一次進(jìn)入程序
if (![[[NSUserDefaults standardUserDefaults] objectForKey:@"isFirst"] isEqualToString:@"yes"]) {
      //顯示提示
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"tishi" message:@"" delegate:self cancelButtonTitle:@"曉得了" otherButtonTitles: nil];
    [alert show];
    [[NSUserDefaults standardUserDefaults]setObject:@"yes" forKey:@"isFirst"];
  }

動(dòng)畫(huà)效果和上一個(gè)是一種效果,具體代碼請(qǐng)看我的gibHub,和上一個(gè)項(xiàng)目在一個(gè)地址里面,這個(gè)在 SwipeGesturePageBlurDemo 分支中.

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論