我正在尝试在我的app中实现泛洪填充算法。我从GitHub获得了一些代码。我需要以int的形式传递目标颜色和替换颜色。 我试过如下,
const CGFloat *components = CGColorGetComponents(color.CGColor);
NSString *colorAsString = [NSString stringWithFormat:@"%f,%f,%f,%f", components[0], components[1], components[2], components[3]];
NSLog(@"colors original is %f %f %f %f",components[0],components[1], components[2], components[3]);
NSLog(@"original color is %d",[colorAsString intValue]);
UIColor *targetColor=[UIColor redColor];
const CGFloat *target = CGColorGetComponents(targetColor.CGColor);
NSString *colorAstarget = [NSString stringWithFormat:@"%f,%f,%f,%f", target[0], target[1], target[2], target[3]];
NSLog(@"colors target is %f %f %f %f",target[0], target[1], target[2], target[3]);
NSLog(@"target color is %d",[colorAstarget intValue]);
但是我在NSLogs中得到1,所以洪水填充返回0。 请帮我 感谢