float scale = [[UIScreen mainScreen] scale]; //得到設(shè)備的分辨率
scale = 1 代表設(shè)備是320480的分辨率(就是iPhone 4之前的設(shè)備)
scale = 2 代表設(shè)備是640969的分辨率
scale = 3 代表3x(就是iPhone 6plus的分辨率)
結(jié)構(gòu)體轉(zhuǎn)換字符串
NSString * NSStringFromCGPoint(CGPoint point);//點(diǎn)
NSString * NSStringFromCGVector(CGVector vector);//矢量點(diǎn)
NSString * NSStringFromCGSize(CGSize size);
NSString * NSStringFromCGRect(CGRect rect);
NSString * NSStringFromCGAffineTransform(CGAffineTransform transform);
NSString * NSStringFromUIEdgeInsets(UIEgeInsets insets);
NSString * NSStringFromUIOffset(UIOffset offset);
字符串轉(zhuǎn)結(jié)構(gòu)體
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不需要考慮設(shè)備是32位還是64位
NSUInteger為無(wú)符號(hào)基礎(chǔ)類型
NSNumber是一個(gè)類兔朦,NSInteger為基礎(chǔ)類型
if ([@“\n” rangeOfString:@“這是個(gè)帶有換行的字符串\n”].location != NSNotFound) {
NSLog(@“這個(gè)字符串中有\(zhòng)n”);
}
//rangeOfString搜索字符串字段
//NSNotFound表示請(qǐng)求操作的內(nèi)容不存在
//軟件信息
[[UIDevice currentDevice] systemName];//系統(tǒng)名字
[[UIDevice currentDevice] systemVersion];//系統(tǒng)版本號(hào)
[[UIDevice currentDevice] uniqueIdentifier];//
[[UIDevice currentDevice] model];
[[UIDevice currentDevice] name];
//硬件信息
[UIDevice platform];//平臺(tái)
[UIDevice cpuFrequency];//CPU信息
[UIDevice busFrequency];//總線
[UIDevice totalMemory];//總內(nèi)存
[UIDevice userMemory];//已經(jīng)使用的內(nèi)存
改變textfield光標(biāo)顏色
[[UITextField appearance] setTintColor:[UIColor greenColor]];
打印視圖樹(shù)
- (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];
}
}