cdts/xdts-ios 3/TreeHole/Code/Base/PYImageView.m

34 lines
756 B
Mathematica
Raw Permalink Normal View History

2023-07-27 09:20:00 +08:00
//
// PYImageView.m
// Food
//
// Created by ko1o on 2019/7/27.
// Copyright © 2019 ko1o. All rights reserved.
//
#import "PYImageView.h"
@implementation PYImageView
- (instancetype)init
{
if (self = [super init]) {
self.backgroundColor = UIColor.clearColor;
self.contentMode = UIViewContentModeScaleAspectFill;
self.clipsToBounds = YES;
self.image = PYPlaceholderImage;
}
return self;
}
-(void)setImageUrl:(NSString *)imageUrl
{
_imageUrl = imageUrl;
if ([imageUrl hasPrefix:@"http"] || [imageUrl hasPrefix:@"file"]) {
[self sd_setImageWithURL:[NSURL URLWithString:imageUrl?: @""] placeholderImage:[UIImage new]];
} else {
self.image = ImageNamed(imageUrl);
}
}
@end