直播带货源码,iOS 获取图片主题色
直播带货源码,iOS 获取图片主题色
- (void)getMostColorFormImage:(UIImage *)image{
WEAKSELF
[image getPaletteImageColorWithMode:ALL_MODE_PALETTE withCallBack:^(PaletteColorModel *recommendColor, NSDictionary *allModeColorDic,NSError *error) {
NSLog(@"获取主题色-----%@",allModeColorDic);
__block CGFloat maxPercentage=0;
__block PaletteColorModel * mostColorModel = recommendColor;
[allModeColorDic.allValues enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if([obj isKindOfClass:[PaletteColorModel class]]){
PaletteColorModel *model = obj;
if(model.percentage*100>maxPercentage){
maxPercentage = model.percentage*100;
mostColorModel = model;
}
}
}];
NSString * mosrColorStr = [mostColorModel.imageColorString stringByReplacingOccurrencesOfString:@"#" withString:@"0x"];
UIColor *color = [UIColor colorWithHexString:mosrColorStr];
}];
}
以上就是直播带货源码,iOS 获取图片主题色, 更多内容欢迎关注之后的文章