QQ 音乐看似简单,但自己手动实现起来,才发现没有那么简单,有好多细节,需要注意。

github : https://github.com/keenleung/QQMusic-OC

一、业务逻辑

首先, 先来瞧瞧 这个小项目的业务逻辑吧:

1)整体:

 QQ音乐项目(OC版) - 实现细节

2)QQ音乐列表:

QQ音乐项目(OC版) - 实现细节 

 3)QQ播放详情:

QQ音乐项目(OC版) - 实现细节

 

做一些模块功能的时候,一定要想到分工处理,不同的操作,应该由不同的功能所抽取出来的业务类或工具类来管理。

 

二、细节分析

1)主界面cell的动画实现

QQ音乐项目(OC版) - 实现细节

 滚动列表的时候,cell显示的方式都是从底部或顶部钻出来

 平成,我们都会在cell创建的时候,直接给cell添xiao'g加动画效果,但是,作为程序员,我们更应该要有面向对象的思想,把动画效果的实现,直接封装到cell里面,然后通过创建的cell对象来调用方法,从而决定使不使用动画效果

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
    
    QQMusicListCell *musicCell = (QQMusicListCell *)cell;
    
    // 执行动画
    // 判断 tableView 的滑动方向
    CGPoint translation = [tableView.panGestureRecognizer translationInView:tableView.superview];
    if (translation.y>0) { // 接近第一行
        
        [musicCell beginAnimation:RE_Rotation];
        
    }else if(translation.y<0){ // 远离第一行
        
        [musicCell beginAnimation:Rotation];
    }
}
View Code

相关文章:

  • 2021-11-14
  • 2022-12-23
  • 2021-12-27
  • 2022-12-23
  • 2023-03-21
  • 2021-06-14
  • 2021-09-27
  • 2022-01-11
猜你喜欢
  • 2021-06-04
  • 2021-10-16
  • 2022-12-23
  • 2021-07-10
  • 2021-06-13
  • 2022-01-08
  • 2022-12-23
相关资源
相似解决方案