【发布时间】:2015-07-15 05:26:01
【问题描述】:
这是将十六进制转换为 rgb 的代码。它工作正常。
#import "UIButton+ButtonClr.h"
@implementation UIButton (ButtonClr)
- (UIColor *)colorFromHexString:(NSString *)hexString {
unsigned rgbValue = 0;
NSScanner *scanner = [NSScanner scannerWithString:hexString];
[scanner setScanLocation:1]; /// bypass '#' character///
[scanner scanHexInt:&rgbValue];
return [UIColor colorWithRed:((rgbValue & 0xFF0000) >> 16)/255.0 green:((rgbValue & 0xFF00) >> 8)/255.0 blue:(rgbValue & 0xFF)/255.0 alpha:1.0];
}
-(void)btnclr
{
UIButton *set1;//i tried many methods here but no use please provide some help full method
}
///set1.backgroundcolor=[self colorFromHexString:@"#ffc400" ];///here i am used this for changing the color but not working.
【问题讨论】:
-
查看答案
-
问题是什么?是否有适合您的想法?什么样的想法?你的标题没有意义,所以如果有问题的话,很难看出是什么问题。
-
@anthon OK 会保重的
标签: ios objective-c uibutton uicolor