Skip to content

Commit

Permalink
fix:uikit修复
Browse files Browse the repository at this point in the history
  • Loading branch information
garenwang committed Jul 4, 2023
1 parent dd698c1 commit b04fdaf
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#import <Foundation/Foundation.h>
#import <QCloudCore/QCloudCore.h>
#import "QCloudGetFilePreviewHtmlResult.h"
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN

/**
Expand Down Expand Up @@ -103,7 +102,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
水印 RGBA(颜色和透明度)
*/
@property (strong, nonatomic)UIColor * htmlfillstyle;
@property (strong, nonatomic)NSString * htmlfillstyle;

/**
水印文字样式 bold 20px Serif 默认
Expand Down
90 changes: 45 additions & 45 deletions QCloudCOSXML/Classes/CI/request/QCloudGetFilePreviewHtmlRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ - (BOOL)buildRequestData:(NSError *__autoreleasing *)error {
[self.requestData setQueryStringParamter:[self base64EncodeString:self.htmlwaterword] withKey:@"htmlwaterword"];

if (self.htmlfillstyle != nil) {
[self.requestData setQueryStringParamter:[self colorToString:self.htmlfillstyle] withKey:@"htmlfillstyle"];
[self.requestData setQueryStringParamter:self.htmlfillstyle withKey:@"htmlfillstyle"];
}

if (self.htmlfront != nil) {
Expand Down Expand Up @@ -157,50 +157,50 @@ - (QCloudSignatureFields *)signatureFields {

return fileds;
}
- (NSArray<NSMutableDictionary *> *)scopesArray {
NSMutableDictionary *dic = [NSMutableDictionary dictionary];
NSArray *separatetmpArray = [self.requestData.serverURL componentsSeparatedByString:@"://"];
NSString *str = separatetmpArray[1];
NSArray *separateArray = [str componentsSeparatedByString:@"."];
dic[@"bucket"] = separateArray[0];
dic[@"region"] = self.runOnService.configuration.endpoint.regionName;
dic[@"prefix"] = self.object;
dic[@"action"] = @"name/cos:GetObject";
NSMutableArray *array = [NSMutableArray array];
[array addObject:dic];
return [array copy];
}

- (NSString *)colorToString:(UIColor *)color {

CGFloat red, green, blue, alpha;
#if SD_UIKIT
if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) {
[color getWhite:&red alpha:&alpha];
green = red;
blue = red;
alpha = 1;
}
#else
@try {
[color getRed:&red green:&green blue:&blue alpha:&alpha];
}
@catch (NSException *exception) {
[color getWhite:&red alpha:&alpha];
green = red;
blue = red;
alpha = 1;
}
#endif

red = roundf(red * 255.f);
green = roundf(green * 255.f);
blue = roundf(blue * 255.f);
alpha = round(alpha * 255.f);
uint hex = (((uint)red << 16) | ((uint)green << 8) | ((uint)blue));

return [self base64EncodeString:[NSString stringWithFormat:@"%06x", hex]];
}
//- (NSArray<NSMutableDictionary *> *)scopesArray {
// NSMutableDictionary *dic = [NSMutableDictionary dictionary];
// NSArray *separatetmpArray = [self.requestData.serverURL componentsSeparatedByString:@"://"];
// NSString *str = separatetmpArray[1];
// NSArray *separateArray = [str componentsSeparatedByString:@"."];
// dic[@"bucket"] = separateArray[0];
// dic[@"region"] = self.runOnService.configuration.endpoint.regionName;
// dic[@"prefix"] = self.object;
// dic[@"action"] = @"name/cos:GetObject";
// NSMutableArray *array = [NSMutableArray array];
// [array addObject:dic];
// return [array copy];
//}
//
//- (NSString *)colorToString:(UIColor *)color {
//
// CGFloat red, green, blue, alpha;
//#if SD_UIKIT
// if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) {
// [color getWhite:&red alpha:&alpha];
// green = red;
// blue = red;
// alpha = 1;
// }
//#else
// @try {
// [color getRed:&red green:&green blue:&blue alpha:&alpha];
// }
// @catch (NSException *exception) {
// [color getWhite:&red alpha:&alpha];
// green = red;
// blue = red;
// alpha = 1;
// }
//#endif
//
// red = roundf(red * 255.f);
// green = roundf(green * 255.f);
// blue = roundf(blue * 255.f);
// alpha = round(alpha * 255.f);
// uint hex = (((uint)red << 16) | ((uint)green << 8) | ((uint)blue));
//
// return [self base64EncodeString:[NSString stringWithFormat:@"%06x", hex]];
//}

- (NSString *)base64EncodeString:(NSString *)string{
NSData *data =[string dataUsingEncoding:NSUTF8StringEncoding];
Expand Down
Binary file not shown.

0 comments on commit b04fdaf

Please sign in to comment.