在iphone中要显示当前网络是否连接只需要两句话就可以搞定了
//显示网络连接状态
UIApplication *app = [UIApplication sharedApplication];
app.networkActivityIndicatorVisible = YES;
iphone开发时某些情况我们可能需要获取用户使用的设备唯一编号来做一些事情。
我现在要实现一个验证的过程,但目前为止ios 最新sdk中还没有提供获取用户手机号码的api,所以只有通过获取设备id做验证了,具体代码很简单。
//获取设备id号
UIDevice *device = [UIDevice currentDevice];//创建设备对象
NSString *deviceUID = [[NSString alloc] initWithString:[device uniqueIdentifier]];
NSLog(@"%@",deviceUID); // 输出设备id
iphone开发 播放短声音
在iphone开发中我们有时候需要播放短音提示用户的操作,iphone api提供了简单的播放短音类,具体实现方法如下
//播放声音变量
CFURLRef soundFileURLRef;
SystemSoundID soundFileObject;
CFBundleRef mainBundle = CFBundleGetMainBundle();
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, CFSTR("page"), CFSTR("aif"), NULL);
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundFileObject);
//播放声音
AudioServicesPlaySystemSound(soundFileObject);
//销毁变量释放内存
AudioServicesDisposeSystemSoundID(soundFileObject);
CFRelease(soundFileURLRef);
iphone开发--获取系统配置文件内容
//获取系统info.plist文件中的键值对
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
//获取软件的版本号
NSString *version = [infoDict objectForKey:@"CFBundleVersion"];
NSLog(@"版本号是=%@",version);
//打印系统plist中所有的键值对
for (id key in infoDict) {
NSLog(@"key:%@,value:%@",key,[infoDict objectForKey:key]);
}
实现圆角图片代码:
UIColor *color=[UIColor colorWithRed:0.95 green:0.95 blue: 0.95 alpha:0];
[asyncImage setBackgroundColor:color];//设置背景透明
/****设置图片圆角begin***/
asyncImage.layer.masksToBounds = YES;
asyncImage.layer.cornerRadius = 5.0;
asyncImage.layer.borderWidth = 0.5;
asyncImage.layer.borderColor = [[UIColor grayColor] CGColor];
/****设置图片圆角end****/