xcode13适配
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
//
|
||||
// UIImage+WaterMark.m
|
||||
// PictureWatermark
|
||||
//
|
||||
// Created by AD-iOS on 15/8/3.
|
||||
// Copyright (c) 2015年 Adinnet. All rights reserved.
|
||||
//
|
||||
|
||||
#import "UIImage+WaterMark.h"
|
||||
|
||||
@implementation UIImage (WaterMark)
|
||||
|
||||
- (UIImage*)imageWaterMarkWithImage:(UIImage *)image imageRect:(CGRect)imgRect alpha:(CGFloat)alpha
|
||||
{
|
||||
return [self imageWaterMarkWithString:nil rect:CGRectZero attribute:nil image:image imageRect:imgRect alpha:alpha];
|
||||
}
|
||||
|
||||
- (UIImage*)imageWaterMarkWithImage:(UIImage*)image imagePoint:(CGPoint)imgPoint alpha:(CGFloat)alpha
|
||||
{
|
||||
return [self imageWaterMarkWithString:nil point:CGPointZero attribute:nil image:image imagePoint:imgPoint alpha:alpha];
|
||||
}
|
||||
|
||||
- (UIImage*)imageWaterMarkWithString:(NSString*)str rect:(CGRect)strRect attribute:(NSDictionary *)attri
|
||||
{
|
||||
return [self imageWaterMarkWithString:str rect:strRect attribute:attri image:nil imageRect:CGRectZero alpha:0];
|
||||
}
|
||||
|
||||
- (UIImage*)imageWaterMarkWithString:(NSString*)str point:(CGPoint)strPoint attribute:(NSDictionary*)attri
|
||||
{
|
||||
return [self imageWaterMarkWithString:str point:strPoint attribute:attri image:nil imagePoint:CGPointZero alpha:0];
|
||||
}
|
||||
|
||||
- (UIImage*)imageWaterMarkWithString:(NSString*)str point:(CGPoint)strPoint attribute:(NSDictionary*)attri image:(UIImage*)image imagePoint:(CGPoint)imgPoint alpha:(CGFloat)alpha
|
||||
{
|
||||
UIGraphicsBeginImageContext(self.size);
|
||||
[self drawAtPoint:CGPointMake(0, 0) blendMode:kCGBlendModeNormal alpha:1.0];
|
||||
if (image) {
|
||||
[image drawAtPoint:imgPoint blendMode:kCGBlendModeNormal alpha:alpha];
|
||||
}
|
||||
|
||||
if (str) {
|
||||
[str drawAtPoint:strPoint withAttributes:attri];
|
||||
}
|
||||
UIImage *resultImage = UIGraphicsGetImageFromCurrentImageContext();
|
||||
UIGraphicsEndImageContext();
|
||||
return resultImage;
|
||||
|
||||
}
|
||||
|
||||
- (UIImage*)imageWaterMarkWithString:(NSString*)str rect:(CGRect)strRect attribute:(NSDictionary *)attri image:(UIImage *)image imageRect:(CGRect)imgRect alpha:(CGFloat)alpha
|
||||
{
|
||||
UIGraphicsBeginImageContext(self.size);
|
||||
[self drawInRect:CGRectMake(0, 0, self.size.width, self.size.height) blendMode:kCGBlendModeNormal alpha:1.0];
|
||||
if (image) {
|
||||
[image drawInRect:imgRect blendMode:kCGBlendModeNormal alpha:alpha];
|
||||
}
|
||||
|
||||
if ([str isKindOfClass:[NSAttributedString class]])
|
||||
{
|
||||
[(NSAttributedString*)str drawInRect:strRect];
|
||||
}
|
||||
else if (str) {
|
||||
[str drawInRect:strRect withAttributes:attri];
|
||||
}
|
||||
UIImage *resultImage = UIGraphicsGetImageFromCurrentImageContext();
|
||||
UIGraphicsEndImageContext();
|
||||
return resultImage;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user