更改服务器图片尺寸

来源:互联网 发布:python的print不换行 编辑:程序博客网 时间:2024/06/12 18:08
  if (json[@"banners"]) {
        NSArray *images = [WKParserUtil array:json key:@"banners"];
        [newObject createAttribute:@"banners" data:images];
    }
    if (json[@"productimgs"]) {
        NSArray *images = [WKParserUtil array:json key:@"productimgs"];
        NSMutableArray *productImages = [NSMutableArray arrayWithCapacity:images.count];
        [images enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:images.count];
            if ([UIScreen mainScreen].scale == 2.f ) {
                dic[@"height"] = @([obj[@"img_height"] floatValue]/2);
            }else if ([UIScreen mainScreen].scale == 3.f )
            {
                dic[@"height"] = @([obj[@"img_height"] floatValue]/3);
                
            }
            
            dic[@"wight"] = obj[@"img_width"];
            NSString *imageUrl = [LEJAppUtil spliceSouurceUrlBySize:CGSizeMake(SCREEN_WIDTH, [obj[@"img_height"] floatValue]) url:obj[@"imgurl"]];
            dic[@"imageUrl"] = imageUrl;
            [productImages addObject:dic];
            
        }];
        [newObject createAttribute:@"productImages" data:productImages];
    }

0 0
原创粉丝点击