如果您在播放音樂,可以使用MPNowPlayingInfoCenter(可在iOS 5.0及更高版本中使用)在鎖定屏幕上設置封面藝術,標題和藝術家等內容。您的代碼看起來是這樣的:
NSMutableDictionary *currentTrackData = [[NSMutableDictionary alloc] init];
[currentTrackData setObject:"Some text" forKey:MPMediaItemPropertyTitle];
MPMediaItemArtwork *mediaItemArtwork =[[MPMediaItemArtwork alloc] initWithImage:[UIImage imageNamed:@"your image path"]];
[currentTrackData setObject:mediaItemArtwork forKey:MPMediaItemPropertyArtwork];
[mediaItemArtwork release];
[MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo = currentTrackData;
不要忘記導入的媒體播放器框架:
#import <MediaPlayer/MediaPlayer.h>