添加背景和背景音乐
来源:互联网 发布:淘宝网黄金生命胶囊 编辑:程序博客网 时间:2024/04/29 14:13
在appdelegate中
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions函数中添加如下代码,实现桌面背景和背景音乐
UIView *beview=[[UIView alloc] initWithFrame:CGRectMake(0,0, 320, 460)];
//创建UIImage对象
UIImage *im=[UIImage imageNamed:@"456.jpg"];
beview.backgroundColor=[UIColorcolorWithPatternImage:im];
// beview.backgroundColor=[UIColor brownColor];
// UIImage *im=[UIImage imageNamed:@"bar.png"];
[self.windowaddSubview:beview];
[beview release];
//播放声音
NSString *mp3Path=[[NSBundlemainBundle] pathForResource:@"Only One"ofType:@"mp3"];
//url分两种 一种是文件url(file) 一种是网络url(http://)
NSURL *url=[NSURL fileURLWithPath:mp3Path];
AVAudioPlayer *player=[[AVAudioPlayeralloc] initWithContentsOfURL:urlerror:nil];
//设置循环次数
player.numberOfLoops=2;
// 告诉系统要播放音频
[player prepareToPlay];
[player play];
[self.windowmakeKeyAndVisible];
return YES;
}
- 添加背景和背景音乐
- 在DOS环境下添加背景音乐、改变背景颜色、冻结屏幕和调用系统时间
- 添加背景音乐
- 添加背景音乐
- 添加背景音乐
- 今天添加了背景音乐和计数器
- cocos2d添加背景音乐和其他音效
- 在html中添加背景音乐和图片
- cocos2d-3.2 添加背景音乐和点击音效
- iOS上视频剪辑片段和添加背景音乐
- 给开始场景添加背景音乐和给按键添加声音
- 添加了计数器,时钟,日历,天气预报和背景音乐
- cocos2d-x入门(5)-添加背景音乐和攻击音效
- 为android程序添加背景音乐和Menu菜单
- cocos2d-x入门(5)-添加背景音乐和攻击音效
- cocos2d-x 添加背景音乐和音效-SimpleAudioEngine
- 多张照片合成视频和给视频添加背景音乐
- ios 给视频截取和给视频添加背景音乐
- 判定系统版本。
- mdev -s的另一种用法
- 删除linux下看到的^M行尾符
- 违心的伤感空间日志_心情好乱纠结着彻底崩溃掉
- 年轻人该有的常识
- 添加背景和背景音乐
- 大数加法
- ORA-00257 archiver error 解决方案
- VS2008中ClassWizard的使用
- vc++深入详解
- sql 中的STR()
- telnet命令及ssh说明
- poj 3087
- 查找整个数据库里某个字段在哪些表里