34 lines
756 B
Mathematica
34 lines
756 B
Mathematica
|
|
//
|
||
|
|
// 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
|