iOS開發--QQ音樂練習,旋轉動畫的實現,音樂工具類的封裝,定時器的提示,SliderBar的事件處理

來源:互聯網
上載者:User

標籤:

一.旋轉動畫的實現

二.音樂工具類的封裝 -- 返回所有歌曲,返回當前播放歌曲,設定當前播放歌曲,返回下一首歌曲,返回上一首歌曲方法的實現

  • 標頭檔

  • .m檔案
     1 #import "ChaosMusicTool.h" 2 #import "MJExtension.h" 3 #import "ChaosMusic.h" 4  5 static NSArray *_musics; 6 static ChaosMusic *_playingMusic; 7  8 @implementation ChaosMusicTool 9 10 + (void)initialize11 {12     if (_musics == nil) {13         _musics = [ChaosMusic objectArrayWithFilename:@"Musics.plist"];14     }15     // 設定預設當前播放歌曲16     _playingMusic = _musics[1];17 }18 19 /** 返回所有歌曲 */20 + (NSArray *)musics21 {22     return _musics;23 }24 /** 返回現正播放歌曲 */25 + (ChaosMusic *)playingMusic26 {27     return _playingMusic;28 }29 /** 返回下一首 */30 + (ChaosMusic *)nextMusic31 {32     // 1.獲得當前播放歌曲的索引33     NSInteger index = [_musics indexOfObject:_playingMusic];34     // 2.判斷下一個索引35     NSInteger nextIndex = ++index;36     if (nextIndex >= _musics.count) { // 是否超出界限37         nextIndex = 0;38     }39     return _musics[nextIndex];40 }41 42 /** 返回上一首 */43 + (ChaosMusic *)previousMusic44 {45     // 1.獲得當前播放歌曲的索引46     NSInteger index = [_musics indexOfObject:_playingMusic];47     // 2.判斷下一個索引48     NSInteger previousIndex = --index;49     if (previousIndex < 0) { // 是否超出界限50         previousIndex = _musics.count - 1;51     }52     return _musics[previousIndex];53 }54 /** 設定當前播放歌曲 */55 + (void)setPlayingMusic:(ChaosMusic *)music56 {57     _playingMusic = music;58 }59 @end

     

三.定時器的提示 -- 定義好了定時器後,添加兩個方法,一個是添加定時器的方法,另一個是移除定時器的方法.

  • 使用的時候也要注意,一定先移除之前的timer,然後再添加timer

四.SliderBar的事件處理

 

iOS開發--QQ音樂練習,旋轉動畫的實現,音樂工具類的封裝,定時器的提示,SliderBar的事件處理

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.