mirror of
https://github.com/danog/Telegram.git
synced 2024-12-04 02:17:51 +01:00
43 lines
1.0 KiB
Objective-C
43 lines
1.0 KiB
Objective-C
#import "TGNeoImageViewModel.h"
|
|
|
|
@implementation TGNeoImageViewModel
|
|
|
|
- (instancetype)initWithImage:(UIImage *)image
|
|
{
|
|
self = [super init];
|
|
if (self != nil)
|
|
{
|
|
_image = image;
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (instancetype)initWithImage:(UIImage *)image tintColor:(UIColor *)tintColor
|
|
{
|
|
self = [super init];
|
|
if (self != nil)
|
|
{
|
|
_image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
|
|
_tintColor = tintColor;
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)drawInContext:(CGContextRef)context
|
|
{
|
|
UIGraphicsPushContext(context);
|
|
if (_tintColor != nil)
|
|
{
|
|
CGContextSaveGState(context);
|
|
CGContextSetFillColorWithColor(context, _tintColor.CGColor);
|
|
}
|
|
|
|
[self.image drawInRect:CGRectMake((self.frame.size.width - self.image.size.width) / 2, (self.frame.size.height - self.image.size.height) / 2, self.image.size.width, self.image.size.height)];
|
|
|
|
if (_tintColor)
|
|
CGContextRestoreGState(context);
|
|
UIGraphicsPopContext();
|
|
}
|
|
|
|
@end
|