iOS NSString 转HEX(c)

#define HEXCOLOR(c)                         [UIColor colorWithRed:((c>>16)&0xFF)/255.0 green:((c>>8)&0xFF)/255.0 blue:(c&0xFF)/255.0 alpha:1.0];

baseView.backgroundColor = HEXCOLOR(strtoul([@"0xf74545" UTF8String],0,16));

时间: 2024-11-05 16:10:35

iOS NSString 转HEX(c)的相关文章

iOS NSString的学习熟悉

对于字符串频繁的切割,合并,插入等操作,优先使用NSMutableString类. 这里讨论的是NSString.然后就是贴代码: 1 -(void)stringDemo{ 2 NSLog(@"____________________________"); 3 4 NSString *string = [[NSString alloc] initWithString:@"Hi,woods!"]; 5 NSLog(@"%@", string); 6

ios NSString字符串如何转为NSNumber(已解决)

今天同事问我 NSString字符串如何转为NSNumber,思考了一下解决了 思路:先将字符串转为NSInteger类型,再通过NSNumber的创建方法@(数字)即可实现 NSString * str = @"890909"; // 字符串转为NSInteger类型 NSInteger num = [str integerValue]; NSLog(@"%li",num); // 字符串转为NSNumber对象类型 NSNumber * nums = @(num

iOS NSString 如何写get方法

iOS NSString 属性使用 get方法时 get写法在arc下无法通过编译 可以通过如下方法来间接实现,实现方法如下: http://www.cnblogs.com/love-lie/archive/2012/06/25/2561566.html such as: #import <Cocoa/Cocoa.h> @interface Photo : NSObject { NSString* caption; NSString* photographer; } - (NSString*)

iOS: [NSString hash]出现同样的hash值问题

问题原因: At least there are special circumstances for which this unreliability kicks in. Comparing [a hash] and [b hash] of two different NSString is safe when: the strings' length is shorter or equal to 96 characters. [a length] is different to [b leng

ios NSString常见的字符串操作 分割 查找

1.NSString *str = [[NSString alloc]init];     //简单粗暴,基本用不到 2.NSString *str = [[NSString alloc]initWithFormat:@"xxx%@", str]; //最喜欢的常见方式了 3.NSString *str = [[NSString alloc]initWithString:str]; 4.NSString *str = [[NSString alloc]initWithNSData:(N

iOS NSString追加字符串的方法

第一种: NSArray *array = [NSArray arrayWithObjects:@"Hello",@" ",@"world", @"!", nil]; NSString *printStr = @""; for(int i = 0; i < [array count]; i++){ printStr = [printStr stringByAppendingFormat:@"

iOS NSString 与NSData转化

1. 字符串转Data NSString * str =@"str"; NSData *data =[str dataUsingEncoding:NSUTF8StringEncoding]; 2.NSData 转NSString NSString * str  =[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; 3.data 转char NSData *data; char * haha=[data 

iOS NSString的常用用法

//1.创建常量字符串. NSString *astring = @"This is a String!"; //2.创建空字符串,给予赋值. NSString *astring = [[NSString alloc] init]; astring = @"This is a String!"; [astring release]; NSLog(@"astring:%@",astring); // NSString *astring = [[NS

iOS NSString 字符串处理:截取字符串、匹配字符串、分隔字符串

用到老是要去找,还是记下来方便!!! 1.截取字符串 NSString*string [email protected]"tate_zwt";string = [string substringToIndex:3];//截取下标7之后的字符串WTLog(@"截取的值为:%@",string); 2.匹配字符串NSString*string [email protected]"tate_zwt";NSRangerange = [stringrang