系统判断

float scale = [[UIScreen mainScreen] scale]; //得到设备的分辨率
scale = 1 代表设备是320480的分辨率(就是iPhone 4之前的设备)
scale = 2 代表设备是640
969的分辨率
scale = 3 代表3x(就是iPhone 6plus的分辨率)

结构体转换字符串
NSString * NSStringFromCGPoint(CGPoint point);//点
NSString * NSStringFromCGVector(CGVector vector);//矢量点
NSString * NSStringFromCGSize(CGSize size);
NSString * NSStringFromCGRect(CGRect rect);
NSString * NSStringFromCGAffineTransform(CGAffineTransform transform);
NSString * NSStringFromUIEdgeInsets(UIEgeInsets insets);
NSString * NSStringFromUIOffset(UIOffset offset);
字符串转结构体
CGPoint CGPointFromString(NSString * string);
CGVector CGVectorFromString(NSString * string);
CGSize CGSizeFromString(NSString * string);
CGRect CGRectFromString(NSString * string);
CGAffineTransform CGAffineTransformFromString(NSString * string);
UIEdgeInsets UIEdgeInsetsFromString(NSString * string);
UIOffset UIOffsetFromString(NSString * string);

NSInteger相比int不需要考虑设备是32位还是64位
NSUInteger为无符号基础类型
NSNumber是一个类,NSInteger为基础类型

if ([@“\n” rangeOfString:@“这是个带有换行的字符串\n”].location != NSNotFound) {
NSLog(@“这个字符串中有\n”);
}
//rangeOfString搜索字符串字段
//NSNotFound表示请求操作的内容不存在

//软件信息
[[UIDevice currentDevice] systemName];//系统名字
[[UIDevice currentDevice] systemVersion];//系统版本号
[[UIDevice currentDevice] uniqueIdentifier];//
[[UIDevice currentDevice] model];
[[UIDevice currentDevice] name];
//硬件信息
[UIDevice platform];//平台
[UIDevice cpuFrequency];//CPU信息
[UIDevice busFrequency];//总线
[UIDevice totalMemory];//总内存
[UIDevice userMemory];//已经使用的内存

改变textfield光标颜色
[[UITextField appearance] setTintColor:[UIColor greenColor]];

打印视图树

- (void)logViewTree{
    for (UIView *view in self.view.subviews) {
        NSLog(@"\nView%@,Frame%@\n",view,NSStringFromCGRect(view.frame));
    }
    NSLog(@"The view tree:\n%@\n",[self displayViews:self.view]);
}
- (NSString *)displayViews:(UIView *)view{
    NSMutableString * string =  [[NSMutableString alloc]init];
    [self dumpView:view atIndent:0 into:string];
    return string;
}
- (void)dumpView:(UIView *)view atIndent:(int)indent into:(NSMutableString *)string {
    for (int i = 0; i < indent; i++) [string appendString:@"--"];
    [string appendFormat:@"[%2d] %@\n",indent,[[view class] description]];
    for (UIView * bview in [view subviews]) {
        [self dumpView:bview atIndent:indent + 1 into:string];
    }
}
系统判断_第1张图片
NSLog的格式.png

你可能感兴趣的:(系统判断)