From 7b02207537d35bfa1714bf8beafc921f717d100a Mon Sep 17 00:00:00 2001
From: 单军华
Date: Wed, 11 Jul 2018 10:47:42 +0800
Subject: [PATCH] 首次上传
---
screendisplay/Pods/YYCategories/YYCategories/Foundation/NSBundle+YYAdd.m | 87 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 87 insertions(+), 0 deletions(-)
diff --git a/screendisplay/Pods/YYCategories/YYCategories/Foundation/NSBundle+YYAdd.m b/screendisplay/Pods/YYCategories/YYCategories/Foundation/NSBundle+YYAdd.m
new file mode 100755
index 0000000..01d665c
--- /dev/null
+++ b/screendisplay/Pods/YYCategories/YYCategories/Foundation/NSBundle+YYAdd.m
@@ -0,0 +1,87 @@
+//
+// NSBundle+YYAdd.m
+// YYCategories <https://github.com/ibireme/YYCategories>
+//
+// Created by ibireme on 14/10/20.
+// Copyright (c) 2015 ibireme.
+//
+// This source code is licensed under the MIT-style license found in the
+// LICENSE file in the root directory of this source tree.
+//
+
+#import "NSBundle+YYAdd.h"
+#import "NSString+YYAdd.h"
+#import "YYCategoriesMacro.h"
+
+YYSYNTH_DUMMY_CLASS(NSBundle_YYAdd)
+
+@implementation NSBundle (YYAdd)
+
++ (NSArray *)preferredScales {
+ static NSArray *scales;
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ CGFloat screenScale = [UIScreen mainScreen].scale;
+ if (screenScale <= 1) {
+ scales = @[@1,@2,@3];
+ } else if (screenScale <= 2) {
+ scales = @[@2,@3,@1];
+ } else {
+ scales = @[@3,@2,@1];
+ }
+ });
+ return scales;
+}
+
++ (NSString *)pathForScaledResource:(NSString *)name ofType:(NSString *)ext inDirectory:(NSString *)bundlePath {
+ if (name.length == 0) return nil;
+ if ([name hasSuffix:@"/"]) return [self pathForResource:name ofType:ext inDirectory:bundlePath];
+
+ NSString *path = nil;
+ NSArray *scales = [self preferredScales];
+ for (int s = 0; s < scales.count; s++) {
+ CGFloat scale = ((NSNumber *)scales[s]).floatValue;
+ NSString *scaledName = ext.length ? [name stringByAppendingNameScale:scale]
+ : [name stringByAppendingPathScale:scale];
+ path = [self pathForResource:scaledName ofType:ext inDirectory:bundlePath];
+ if (path) break;
+ }
+
+ return path;
+}
+
+- (NSString *)pathForScaledResource:(NSString *)name ofType:(NSString *)ext {
+ if (name.length == 0) return nil;
+ if ([name hasSuffix:@"/"]) return [self pathForResource:name ofType:ext];
+
+ NSString *path = nil;
+ NSArray *scales = [NSBundle preferredScales];
+ for (int s = 0; s < scales.count; s++) {
+ CGFloat scale = ((NSNumber *)scales[s]).floatValue;
+ NSString *scaledName = ext.length ? [name stringByAppendingNameScale:scale]
+ : [name stringByAppendingPathScale:scale];
+ path = [self pathForResource:scaledName ofType:ext];
+ if (path) break;
+ }
+
+ return path;
+}
+
+- (NSString *)pathForScaledResource:(NSString *)name ofType:(NSString *)ext inDirectory:(NSString *)subpath {
+ if (name.length == 0) return nil;
+ if ([name hasSuffix:@"/"]) return [self pathForResource:name ofType:ext];
+
+ NSString *path = nil;
+ NSArray *scales = [NSBundle preferredScales];
+ for (int s = 0; s < scales.count; s++) {
+ CGFloat scale = ((NSNumber *)scales[s]).floatValue;
+ NSString *scaledName = ext.length ? [name stringByAppendingNameScale:scale]
+ : [name stringByAppendingPathScale:scale];
+ path = [self pathForResource:scaledName ofType:ext inDirectory:subpath];
+ if (path) break;
+ }
+
+ return path;
+}
+
+@end
--
Gitblit v1.8.0