cdts/xdts-ios 3/TreeHole/Code/Gategory/UIImageEx/UIImage+Gradient.h
2023-07-27 09:20:00 +08:00

30 lines
905 B
Objective-C
Executable File

//
// UIImage+Gradient.h
// testLayer
//
// Created by tb on 17/3/17.
// Copyright © 2017年 com.tb. All rights reserved.
//
#import <UIKit/UIKit.h>
typedef NS_ENUM(NSInteger, GradientType) {
GradientFromTopToBottom = 1, //从上到下
GradientFromLeftToRight, //从做到右
GradientFromLeftTopToRightBottom, //从上到下
GradientFromLeftBottomToRightTop //从上到下
};
@interface UIImage (Gradient)
/**
* 根据给定的颜色,生成渐变色的图片
* @param imageSize 要生成的图片的大小
* @param colorArr 渐变颜色的数组
* @param percents 渐变颜色的占比数组
* @param gradientType 渐变色的类型
*/
- (UIImage *)createImageWithSize:(CGSize)imageSize gradientColors:(NSArray *)colorArr percentage:(NSArray *)percents gradientType:(GradientType)gradientType;
@end