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

iOS開(kāi)發(fā)中仿Tumblr點(diǎn)贊心破碎動(dòng)畫(huà)效果

 更新時(shí)間:2017年04月13日 15:53:15   作者:韓俊強(qiáng)  
這篇文章主要介紹了iOS開(kāi)發(fā)中仿Tumblr點(diǎn)贊心破碎動(dòng)畫(huà)效果,本文圖文并茂給大家介紹的非常詳細(xì),需要的朋友可以參考下

 最近Tumblr輕博客無(wú)論是web端還是移動(dòng)端,都非常受歡迎,簡(jiǎn)單調(diào)研了一下,其中動(dòng)畫(huà)是我感興趣的,特此寫(xiě)了個(gè)仿Tumblr點(diǎn)贊心破碎動(dòng)畫(huà);

1.首先看下效果:

2.模仿Tumblr中的效果應(yīng)用如下:

原理:使用按鈕點(diǎn)擊Action增加兩個(gè)事件,通過(guò)改變背景hidden和frame,切換圖片,增加動(dòng)畫(huà)效果等;

setupUI及touch Action:

<span style="font-size:14px;">- (void)setupUI 
{ 
  // 點(diǎn)擊的btn 
  UIButton *praiseBtn = [UIButton buttonWithType:UIButtonTypeCustom]; 
  praiseBtn.frame = CGRectMake(100, 200, KKPraiseBtnWH, KKPraiseBtnWH); 
  [praiseBtn setImage:[UIImage imageNamed:@"icon_like"] forState:UIControlStateNormal]; 
  [praiseBtn setImage:[UIImage imageNamed:@"icon_likeon"] forState:UIControlStateSelected]; 
  [self.view addSubview:praiseBtn]; 
  [praiseBtn addTarget:self action:@selector(clickTheBtn:) forControlEvents:UIControlEventTouchUpInside]; 
  _praiseBtn = praiseBtn; 
  // 放大后的btn 
  _coverBtn = [UIButton buttonWithType:UIButtonTypeCustom]; 
  _coverBtn.frame = praiseBtn.frame; 
  _coverBtn.alpha = 0; 
  [_coverBtn setImage:[UIImage imageNamed:@"big"] forState:UIControlStateSelected]; 
  [_coverBtn setImage:[UIImage imageNamed:@"big"] forState:UIControlStateNormal]; 
  [self.view insertSubview:_coverBtn belowSubview:praiseBtn]; 
  _cancelPraiseImg = [[UIImageView alloc]initWithFrame:CGRectMake(80, 150, KKPraiseBtnWH*2, KKPraiseBtnWH*2*KKToBrokenHeartWH)]; 
  _cancelPraiseImg.hidden = YES; 
  _cancelPraiseImg.centerX = _praiseBtn.centerX; 
  [self.view addSubview:_cancelPraiseImg]; 
} 
-(void)clickTheBtn:(UIButton *)btn 
{ 
  [self playAnimation]; 
  btn.userInteractionEnabled = NO; 
  btn.selected = !btn.selected; 
} 
-(void)playAnimation{ 
  if (!_praiseBtn.selected) { 
    _coverBtn.alpha = 1; 
    [UIView animateWithDuration:1.0f animations:^{ 
      _coverBtn.frame = CGRectMake(80, 100, KKPraiseBtnWH*2, KKPraiseBtnWH*2); 
      CAKeyframeAnimation *anima = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation"]; 
      NSValue *value1 = [NSNumber numberWithFloat:-M_PI/180*5]; 
      NSValue *value2 = [NSNumber numberWithFloat:M_PI/180*5]; 
      NSValue *value3 = [NSNumber numberWithFloat:-M_PI/180*5]; 
      anima.values = @[value1,value2,value3]; 
      anima.repeatCount = MAXFLOAT; 
      [_coverBtn.layer addAnimation:anima forKey:nil]; 
      _coverBtn.alpha = 0; 
      _coverBtn.centerX = _praiseBtn.centerX; 
    } completion:^(BOOL finished) { 
      _coverBtn.frame = _praiseBtn.frame; 
      _praiseBtn.userInteractionEnabled = YES; 
    }]; 
  } else { 
    _cancelPraiseImg.hidden = NO; 
    NSArray *imgArr = [NSArray arrayWithObjects:[UIImage imageNamed:@"icon_like_broken1"],[UIImage imageNamed:@"icon_like_broken2"],[UIImage imageNamed:@"icon_like_broken3"],[UIImage imageNamed:@"icon_like_broken4"], nil nil]; 
    _cancelPraiseImg.animationImages = imgArr; 
    _cancelPraiseImg.animationDuration = KKBorkenTime; 
    _cancelPraiseImg.animationRepeatCount = 1; 
    [_cancelPraiseImg startAnimating]; 
    [UIView animateWithDuration:KKBorkenTime animations:^{ 
      _cancelPraiseImg.frame = CGRectMake(80, 200, KKPraiseBtnWH*2, KKPraiseBtnWH*2*KKToBrokenHeartWH); 
      _cancelPraiseImg.alpha = 0; 
    }completion:^(BOOL finished) { 
      _cancelPraiseImg.frame = CGRectMake(80, 150, KKPraiseBtnWH*2, KKPraiseBtnWH*2*KKToBrokenHeartWH); 
      _cancelPraiseImg.alpha = 1; 
      _praiseBtn.userInteractionEnabled = YES; 
    }]; 
  } 
}</span> 

以上所述是小編給大家介紹的iOS開(kāi)發(fā)中仿Tumblr點(diǎn)贊心破碎動(dòng)畫(huà)效果,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

  • IOS開(kāi)發(fā)之適配iOS10及Xcode8的注意點(diǎn)

    IOS開(kāi)發(fā)之適配iOS10及Xcode8的注意點(diǎn)

    這篇文章主要介紹了IOS開(kāi)發(fā)之適配iOS10及Xcode8的注意點(diǎn),本文給大家介紹了可能出現(xiàn)的問(wèn)題及相應(yīng)的解決方法,非常不錯(cuò)具有參考借鑒價(jià)值,感興趣的朋友一起看看
    2016-10-10
  • iOS NSDate中關(guān)于夏令時(shí)的坑

    iOS NSDate中關(guān)于夏令時(shí)的坑

    這篇文章主要給大家介紹了關(guān)于iOS NSDate中夏令時(shí)的坑,以及iOS 時(shí)間字符串&NSDate&時(shí)間戳 相互轉(zhuǎn)換的相關(guān)內(nèi)容,分享出來(lái)供大家參考學(xué)習(xí),需要的朋友可以參考借鑒,下面隨小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2018-08-08
  • 實(shí)例講解iOS中的CATransition轉(zhuǎn)場(chǎng)動(dòng)畫(huà)使用

    實(shí)例講解iOS中的CATransition轉(zhuǎn)場(chǎng)動(dòng)畫(huà)使用

    CATransition類(lèi)為應(yīng)用程序的轉(zhuǎn)場(chǎng)動(dòng)畫(huà)提供了很多可控制參數(shù),接下來(lái)我們就以幾個(gè)實(shí)例講解iOS中的CATransition轉(zhuǎn)場(chǎng)動(dòng)畫(huà)使用,需要的朋友可以參考下
    2016-06-06
  • iOS開(kāi)發(fā)之tableView cell的展開(kāi)收回功能實(shí)現(xiàn)代碼

    iOS開(kāi)發(fā)之tableView cell的展開(kāi)收回功能實(shí)現(xiàn)代碼

    本文介紹了iOS開(kāi)發(fā)之tableView cell的展開(kāi)收回功能實(shí)現(xiàn)代碼,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-01-01
  • iOS獲取當(dāng)前設(shè)備WiFi信息的方法

    iOS獲取當(dāng)前設(shè)備WiFi信息的方法

    很多公司現(xiàn)在都在做免費(fèi)WIFI,車(chē)站、公交、地鐵、餐廳,只要是人員密集流動(dòng)的地方就有WIFI,免費(fèi)WIFI從最初的網(wǎng)頁(yè)認(rèn)證方式也逐漸向客戶(hù)端認(rèn)證方式偏移。本文主要介紹iOS獲取當(dāng)前設(shè)備WiFi信息的方法,有需要的可以參考借鑒。
    2016-09-09
  • iOS仿微信圖片分享界面實(shí)現(xiàn)代碼

    iOS仿微信圖片分享界面實(shí)現(xiàn)代碼

    這篇文章主要為大家詳細(xì)介紹了iOS仿微信相冊(cè)界面翻轉(zhuǎn)過(guò)渡動(dòng)畫(huà)效果,微信采用界面翻轉(zhuǎn)的過(guò)渡動(dòng)畫(huà)跳轉(zhuǎn)到評(píng)論界面,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-11-11
  • iOS的UI開(kāi)發(fā)中Button的基本編寫(xiě)方法講解

    iOS的UI開(kāi)發(fā)中Button的基本編寫(xiě)方法講解

    這篇文章主要介紹了iOS的UI開(kāi)發(fā)中Button的基本編寫(xiě)方法講解,代碼基于傳統(tǒng)的Objective-C,需要的朋友可以參考下
    2015-11-11
  • ios的簽名機(jī)制詳解

    ios的簽名機(jī)制詳解

    這篇文章主要介紹了ios的簽名機(jī)制的相關(guān)資料,幫助大家更好的理解和學(xué)習(xí)使用ios開(kāi)發(fā),感興趣的朋友可以了解下
    2021-04-04
  • iOS CoreAnimation 圖層幾何學(xué)

    iOS CoreAnimation 圖層幾何學(xué)

    本文主要介紹了iOS CoreAnimation圖層幾何學(xué),圖層幾何所講主要是有關(guān)圖層的位置,尺寸等幾何類(lèi)屬性。具有很好的參考價(jià)值。下面跟著小編一起來(lái)看下吧
    2017-03-03
  • swift 隱式可選型實(shí)例詳解

    swift 隱式可選型實(shí)例詳解

    這篇文章主要介紹了 swift 隱式可選型實(shí)例詳解的相關(guān)資料,需要的朋友可以參考下
    2017-06-06

最新評(píng)論