QQ 音乐看似简单,但自己手动实现起来,才发现没有那么简单,有好多细节,需要注意。
github : https://github.com/keenleung/QQMusic-OC
一、业务逻辑
首先, 先来瞧瞧 这个小项目的业务逻辑吧:
1)整体:
2)QQ音乐列表:
3)QQ播放详情:
做一些模块功能的时候,一定要想到分工处理,不同的操作,应该由不同的功能所抽取出来的业务类或工具类来管理。
二、细节分析
1)主界面cell的动画实现
滚动列表的时候,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]; } }