iphone 小代码总结

在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****/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值