├── .github └── FUNDING.yml ├── .gitignore ├── .travis.yml ├── Example ├── OC │ ├── SwiftyFitsize │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Assets.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ └── Contents.json │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ ├── Info.plist │ │ ├── ViewController.h │ │ ├── ViewController.m │ │ └── main.m │ ├── Tests │ │ ├── Info.plist │ │ └── SwiftyFitsize_OCTests.m │ └── UITests │ │ ├── Info.plist │ │ └── SwiftyFitsize_OCUITests.m ├── Podfile ├── Scene │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ ├── AccentColor.colorset │ │ │ └── Contents.json │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Info.plist │ ├── SceneDelegate.swift │ └── ViewController.swift ├── Swift │ ├── SwiftyFitsize │ │ ├── AppDelegate.swift │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.xib │ │ │ └── Main.storyboard │ │ ├── FitsizeView.swift │ │ ├── FitsizeView.xib │ │ ├── Images.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ ├── Contents.json │ │ │ └── lxf.imageset │ │ │ │ ├── Contents.json │ │ │ │ └── lxf@2x.png │ │ ├── Info.plist │ │ ├── LandscapeViewController.swift │ │ ├── PortraitViewController.swift │ │ └── ViewController.swift │ └── Tests │ │ ├── Info.plist │ │ └── Tests.swift ├── SwiftyFitsize.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── SwiftyFitsize-Swift.xcscheme └── SwiftyFitsizePackage.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ ├── IDEWorkspaceChecks.plist │ │ └── swiftpm │ │ └── Package.resolved │ └── xcshareddata │ └── xcschemes │ └── SwiftyFitsize_OC.xcscheme ├── LICENSE ├── Package.swift ├── README.md ├── Screenshots ├── exhibition.png ├── fitsize-height.jpg ├── fitsize-reduce.jpg ├── flexible-force.jpg ├── ipad.png ├── ipad1.png ├── xib-constraint.png ├── xib-constraint1.png ├── xib-font.png └── xib-font1.png ├── Sources ├── SwiftyFitsize │ ├── SwiftyFitsize.swift │ ├── SwiftyFitsizeConfig.swift │ ├── SwiftyFitsizeHeader.swift │ └── WrappedSwiftyFitsize.swift └── SwiftyFitsizeOCSupport │ ├── empty.c │ └── include │ └── SwiftyFitsizeOCSupport │ └── SwiftyFitsize.h ├── SwiftyFitsize.podspec ├── _Pods.xcodeproj └── fastlane ├── Fastfile ├── README.md └── actions └── remove_git_tag.rb /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | # github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | # patreon: # Replace with a single Patreon username 5 | # open_collective: # Replace with a single Open Collective username 6 | # ko_fi: # Replace with a single Ko-fi username 7 | # tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | # community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | # liberapay: # Replace with a single Liberapay username 10 | # issuehunt: # Replace with a single IssueHunt username 11 | # otechie: # Replace with a single Otechie username 12 | # lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | # custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 14 | 15 | ko_fi: linxunfeng 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | ## Playgrounds 32 | timeline.xctimeline 33 | playground.xcworkspace 34 | 35 | # Swift Package Manager 36 | # 37 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 38 | # Packages/ 39 | # Package.pins 40 | # Package.resolved 41 | .build/ 42 | .swiftpm 43 | 44 | # CocoaPods 45 | # 46 | # We recommend against adding the Pods directory to your .gitignore. However 47 | # you should judge for yourself, the pros and cons are mentioned at: 48 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 49 | # 50 | Example/Pods/ 51 | Example/Podfile.lock 52 | Example/*.xcworkspace 53 | 54 | # Carthage 55 | # 56 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 57 | # Carthage/Checkouts 58 | 59 | Carthage/Build 60 | 61 | # fastlane 62 | # 63 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 64 | # screenshots whenever they are needed. 65 | # For more information about the recommended setup visit: 66 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 67 | 68 | fastlane/report.xml 69 | fastlane/Preview.html 70 | fastlane/screenshots/**/*.png 71 | fastlane/test_output 72 | 73 | # AppCode 74 | .idea 75 | 76 | # VSCode 77 | .vscode/settings.json -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | osx_image: xcode12.2 2 | language: swift 3 | podfile: Example/Podfile 4 | 5 | before_install: 6 | - gem install xcpretty 7 | - gem install cocoapods --pre 8 | - pod --version 9 | - pod setup --silent > /dev/null 10 | - pod repo update --silent 11 | - xcpretty --version 12 | - xcodebuild -version 13 | - xcodebuild -showsdks 14 | 15 | script: 16 | - pod lib lint --allow-warnings --no-clean --verbose -------------------------------------------------------------------------------- /Example/OC/SwiftyFitsize/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // SwiftyFitsize-OC 4 | // 5 | // Created by LinXunFeng on 2018/11/15. 6 | // Copyright © 2018 CocoaPods. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /Example/OC/SwiftyFitsize/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // SwiftyFitsize-OC 4 | // 5 | // Created by LinXunFeng on 2018/11/15. 6 | // Copyright © 2018 CocoaPods. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | @import SwiftyFitsize; 11 | 12 | @interface AppDelegate () 13 | 14 | @end 15 | 16 | @implementation AppDelegate 17 | 18 | 19 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 20 | // Override point for customization after application launch. 21 | 22 | // 全局配置 23 | [SwiftyFitsize referenceWithWidth:414 // 参照的宽度 24 | height:896 // 参照的高度 25 | isIPhoneXSeriesHeight:YES // 参照的设置是否为 x 系列 26 | iPadFitMultiple:0.6 // ipad系数 27 | calcResultType:SwiftyFitCalcResultTypeRound]; // 计算结果类型(这里指定:四舍五入) 28 | 29 | return YES; 30 | } 31 | 32 | 33 | - (void)applicationWillResignActive:(UIApplication *)application { 34 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 35 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 36 | } 37 | 38 | 39 | - (void)applicationDidEnterBackground:(UIApplication *)application { 40 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 41 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 42 | } 43 | 44 | 45 | - (void)applicationWillEnterForeground:(UIApplication *)application { 46 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 47 | } 48 | 49 | 50 | - (void)applicationDidBecomeActive:(UIApplication *)application { 51 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 52 | } 53 | 54 | 55 | - (void)applicationWillTerminate:(UIApplication *)application { 56 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 57 | } 58 | 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /Example/OC/SwiftyFitsize/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /Example/OC/SwiftyFitsize/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Example/OC/SwiftyFitsize/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Example/OC/SwiftyFitsize/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /Example/OC/SwiftyFitsize/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /Example/OC/SwiftyFitsize/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // SwiftyFitsize-OC 4 | // 5 | // Created by LinXunFeng on 2018/11/15. 6 | // Copyright © 2018 CocoaPods. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /Example/OC/SwiftyFitsize/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // SwiftyFitsize-OC 4 | // 5 | // Created by LinXunFeng on 2018/11/15. 6 | // Copyright © 2018 CocoaPods. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | @import SwiftyFitsize; 11 | 12 | // 如果是SPM集成,在OC中使用宏需要额外 @import SwiftyFitsizeOCSupport; 13 | #if __has_include() 14 | @import SwiftyFitsizeOCSupport; 15 | #endif 16 | 17 | #define kFitWidth(value) \ 18 | [SwiftyFitsize fitWithSize:value fitType:SwiftyFitTypeFlexibleWidth reduceValue:20] 19 | 20 | #define kFitWidthRaw(value) \ 21 | [SwiftyFitsize fitWithSize:value fitType:SwiftyFitTypeFlexibleWidth reduceValue:20 calcResultType:SwiftyFitCalcResultTypeRaw] 22 | 23 | #define kFitWidthRound(value) \ 24 | [SwiftyFitsize fitWithSize:value fitType:SwiftyFitTypeFlexibleWidth reduceValue:20 calcResultType:SwiftyFitCalcResultTypeRound] 25 | 26 | #define kFitWidthOneDecimalPlace(value) \ 27 | [SwiftyFitsize fitWithSize:value fitType:SwiftyFitTypeFlexibleWidth reduceValue:20 calcResultType:SwiftyFitCalcResultTypeOneDecimalPlace] 28 | 29 | @interface ViewController () 30 | 31 | @end 32 | 33 | @implementation ViewController 34 | 35 | - (void)viewDidLoad { 36 | [super viewDidLoad]; 37 | 38 | #pragma mark UIFont 39 | UIFont *font = [UIFont systemFontOfSize:14]; 40 | // 以宽适配 41 | UIFont *font1 = font.sf; 42 | UIFont *font2 = font.sfz; 43 | // 以高适配(全屏) 44 | UIFont *font3 = font.sf_fh; 45 | UIFont *font4 = font.sfz_fh; 46 | // 以高适配(安全区域,仅中间) 47 | UIFont *font5 = font.sf_sch; 48 | UIFont *font6 = font.sfz_sch; 49 | // 以高适配(安全区域,不包括刘海) 50 | UIFont *font7 = font.sf_sbh; 51 | UIFont *font8 = font.sfz_sbh; 52 | 53 | // 以宽适配 54 | UIFont *font9 = SF_Font(font); 55 | UIFont *font10 = SFZ_Font(font); 56 | // 以高适配(全屏) 57 | UIFont *font11 = SF_FH_Font(font); 58 | UIFont *font12 = SFZ_FH_Font(font); 59 | // 以高适配(安全区域,仅中间) 60 | UIFont *font13 = SF_SCH_Font(font); 61 | UIFont *font14 = SFZ_SCH_Font(font); 62 | // 以高适配(安全区域,不包括刘海) 63 | UIFont *font15 = SF_SBH_Font(font); 64 | UIFont *font16 = SFZ_SBH_Font(font); 65 | 66 | #pragma mark CGFloat 67 | CGFloat num = 14; 68 | // 以宽适配 69 | CGFloat num1 = SF_Float(num); 70 | CGFloat num2 = SFZ_Float(num); 71 | // 以高适配(全屏) 72 | CGFloat num3 = SF_FH_Float(num); 73 | CGFloat num4 = SFZ_FH_Float(num); 74 | // 以高适配(安全区域,仅中间) 75 | CGFloat num5 = SF_SCH_Float(num); 76 | CGFloat num6 = SFZ_SCH_Float(num); 77 | // 以高适配(安全区域,不包括刘海) 78 | CGFloat num7 = SF_SBH_Float(num); 79 | CGFloat num8 = SFZ_SBH_Float(num); 80 | 81 | #pragma mark CGPoint 82 | CGPoint point = CGPointMake(10, 10); 83 | // 以宽适配 84 | CGPoint point1 = SF_Point(point); 85 | CGPoint point2 = SFZ_Point(point); 86 | // 以高适配(全屏) 87 | CGPoint point3 = SF_FH_Point(point); 88 | CGPoint point4 = SFZ_FH_Point(point); 89 | // 以高适配(安全区域,仅中间) 90 | CGPoint point5 = SF_SCH_Point(point); 91 | CGPoint point6 = SFZ_SCH_Point(point); 92 | // 以高适配(安全区域,不包括刘海) 93 | CGPoint point7 = SF_SBH_Point(point); 94 | CGPoint point8 = SFZ_SBH_Point(point); 95 | 96 | #pragma mark CGSize 97 | CGSize size = CGSizeMake(100, 100); 98 | // 以宽适配 99 | CGSize size1 = SF_Size(size); 100 | CGSize size2 = SFZ_Size(size); 101 | // 以高适配(全屏) 102 | CGSize size3 = SF_FH_Size(size); 103 | CGSize size4 = SFZ_FH_Size(size); 104 | // 以高适配(安全区域,仅中间) 105 | CGSize size5 = SF_SCH_Size(size); 106 | CGSize size6 = SFZ_SCH_Size(size); 107 | // 以高适配(安全区域,不包括刘海) 108 | CGSize size7 = SF_SBH_Size(size); 109 | CGSize size8 = SFZ_SBH_Size(size); 110 | 111 | #pragma mark CGRect 112 | CGRect rect = CGRectMake(10, 10, 100, 100); 113 | // 以宽适配 114 | CGRect rect1 = SF_Rect(rect); 115 | CGRect rect2 = SFZ_Rect(rect); 116 | // 以高适配(全屏) 117 | CGRect rect3 = SF_FH_Rect(rect); 118 | CGRect rect4 = SFZ_FH_Rect(rect); 119 | // 以高适配(安全区域,仅中间) 120 | CGRect rect5 = SF_SCH_Rect(rect); 121 | CGRect rect6 = SFZ_SCH_Rect(rect); 122 | // 以高适配(安全区域,不包括刘海) 123 | CGRect rect7 = SF_SBH_Rect(rect); 124 | CGRect rect8 = SFZ_SBH_Rect(rect); 125 | 126 | #pragma mark UIEdgeInsets 127 | UIEdgeInsets edge = UIEdgeInsetsMake(0, 0, 100, 100); 128 | // 以宽适配 129 | UIEdgeInsets edge1 = SF_EdgeInsets(edge); 130 | UIEdgeInsets edge2 = SFZ_EdgeInsets(edge); 131 | // 以高适配(全屏) 132 | UIEdgeInsets edge3 = SF_FH_EdgeInsets(edge); 133 | UIEdgeInsets edge4 = SFZ_FH_EdgeInsets(edge); 134 | // 以高适配(安全区域,仅中间) 135 | UIEdgeInsets edge5 = SF_SCH_EdgeInsets(edge); 136 | UIEdgeInsets edge6 = SFZ_SCH_EdgeInsets(edge); 137 | // 以高适配(安全区域,不包括刘海) 138 | UIEdgeInsets edge7 = SF_SBH_EdgeInsets(edge); 139 | UIEdgeInsets edge8 = SFZ_SBH_EdgeInsets(edge); 140 | 141 | 142 | 143 | #pragma mark 移除额外尺寸 144 | 145 | /** 146 | 使用情景:列表的左右间距,在不同设备下都为10,其它大小进行等比缩放 147 | 148 | 使用思路:一共减去20,用剩下的大小做适配 149 | */ 150 | CGFloat toFitVal = 40; 151 | 152 | // .globalConfig 153 | // CGFloat fitWidth = [SwiftyFitsize fitWithSize:40 154 | // fitType:SwiftyFitTypeFlexibleWidth 155 | // reduceValue:20]; 156 | CGFloat fitWidth = kFitWidth(toFitVal); 157 | NSLog(@"fitWidth -- %f", fitWidth); 158 | 159 | // .raw 160 | // CGFloat fitWidthRound = [SwiftyFitsize fitWithSize:40 161 | // fitType:SwiftyFitTypeFlexibleWidth 162 | // reduceValue:20 163 | // calcResultType:SwiftyFitCalcResultTypeRound]; 164 | CGFloat fitWidthRaw = kFitWidthRaw(toFitVal); 165 | NSLog(@"fitWidthRaw -- %f", fitWidthRaw); 166 | 167 | // .round 168 | // CGFloat fitWidthRound = [SwiftyFitsize fitWithSize:40 169 | // fitType:SwiftyFitTypeFlexibleWidth 170 | // reduceValue:20 171 | // calcResultType:SwiftyFitCalcResultTypeRound]; 172 | CGFloat fitWidthRound = kFitWidthRound(toFitVal); 173 | NSLog(@"fitWidthRound -- %f", fitWidthRound); 174 | 175 | // .oneDecimalPlace 176 | // CGFloat fitWidthOneDecimalPlace = [SwiftyFitsize fitWithSize:40 177 | // fitType:SwiftyFitTypeFlexibleWidth 178 | // reduceValue:20 179 | // calcResultType:SwiftyFitCalcResultTypeOneDecimalPlace]; 180 | CGFloat fitWidthOneDecimalPlace = kFitWidthOneDecimalPlace(toFitVal); 181 | NSLog(@"fitWidthOneDecimalPlace -- %f", fitWidthOneDecimalPlace); 182 | 183 | } 184 | 185 | @end 186 | -------------------------------------------------------------------------------- /Example/OC/SwiftyFitsize/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // SwiftyFitsize-OC 4 | // 5 | // Created by LinXunFeng on 2018/11/15. 6 | // Copyright © 2018 CocoaPods. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Example/OC/Tests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Example/OC/Tests/SwiftyFitsize_OCTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftyFitsize_OCTests.m 3 | // SwiftyFitsize-OCTests 4 | // 5 | // Created by LinXunFeng on 2018/11/15. 6 | // Copyright © 2018 CocoaPods. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SwiftyFitsize_OCTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation SwiftyFitsize_OCTests 16 | 17 | - (void)setUp { 18 | // Put setup code here. This method is called before the invocation of each test method in the class. 19 | } 20 | 21 | - (void)tearDown { 22 | // Put teardown code here. This method is called after the invocation of each test method in the class. 23 | } 24 | 25 | - (void)testExample { 26 | // This is an example of a functional test case. 27 | // Use XCTAssert and related functions to verify your tests produce the correct results. 28 | } 29 | 30 | - (void)testPerformanceExample { 31 | // This is an example of a performance test case. 32 | [self measureBlock:^{ 33 | // Put the code you want to measure the time of here. 34 | }]; 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /Example/OC/UITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Example/OC/UITests/SwiftyFitsize_OCUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftyFitsize_OCUITests.m 3 | // SwiftyFitsize-OCUITests 4 | // 5 | // Created by LinXunFeng on 2018/11/15. 6 | // Copyright © 2018 CocoaPods. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SwiftyFitsize_OCUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation SwiftyFitsize_OCUITests 16 | 17 | - (void)setUp { 18 | // Put setup code here. This method is called before the invocation of each test method in the class. 19 | 20 | // In UI tests it is usually best to stop immediately when a failure occurs. 21 | self.continueAfterFailure = NO; 22 | 23 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 24 | [[[XCUIApplication alloc] init] launch]; 25 | 26 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 27 | } 28 | 29 | - (void)tearDown { 30 | // Put teardown code here. This method is called after the invocation of each test method in the class. 31 | } 32 | 33 | - (void)testExample { 34 | // Use recording to get started writing UI tests. 35 | // Use XCTAssert and related functions to verify your tests produce the correct results. 36 | } 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /Example/Podfile: -------------------------------------------------------------------------------- 1 | use_frameworks! 2 | 3 | project 'SwiftyFitsize.xcodeproj' 4 | 5 | target 'SwiftyFitsize_OC' do 6 | pod 'SwiftyFitsize', :path => '../' 7 | end 8 | 9 | target 'SwiftyFitsize_Swift' do 10 | pod 'SwiftyFitsize', :path => '../' 11 | 12 | pod 'SnapKit' 13 | 14 | target 'SwiftyFitsize_SwiftTests' do 15 | inherit! :search_paths 16 | 17 | 18 | end 19 | end 20 | 21 | target 'SwiftyFitsize_Scene' do 22 | pod 'SwiftyFitsize', :path => '../' 23 | pod 'SnapKit' 24 | end 25 | -------------------------------------------------------------------------------- /Example/Scene/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // SwiftyFitsize_Scene 4 | // 5 | // Created by LinXunFeng on 2021/8/25. 6 | // Copyright © 2021 CocoaPods. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @main 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 17 | // Override point for customization after application launch. 18 | return true 19 | } 20 | 21 | // MARK: UISceneSession Lifecycle 22 | 23 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 24 | // Called when a new scene session is being created. 25 | // Use this method to select a configuration to create the new scene with. 26 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 27 | } 28 | 29 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 30 | // Called when the user discards a scene session. 31 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 32 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 33 | } 34 | 35 | 36 | } 37 | 38 | -------------------------------------------------------------------------------- /Example/Scene/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Example/Scene/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "1x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "76x76" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "scale" : "2x", 86 | "size" : "83.5x83.5" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "scale" : "1x", 91 | "size" : "1024x1024" 92 | } 93 | ], 94 | "info" : { 95 | "author" : "xcode", 96 | "version" : 1 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /Example/Scene/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Scene/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Example/Scene/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Example/Scene/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UIApplicationSceneManifest 24 | 25 | UIApplicationSupportsMultipleScenes 26 | 27 | UISceneConfigurations 28 | 29 | UIWindowSceneSessionRoleApplication 30 | 31 | 32 | UISceneConfigurationName 33 | Default Configuration 34 | UISceneDelegateClassName 35 | $(PRODUCT_MODULE_NAME).SceneDelegate 36 | UISceneStoryboardFile 37 | Main 38 | 39 | 40 | 41 | 42 | UIApplicationSupportsIndirectInputEvents 43 | 44 | UILaunchStoryboardName 45 | LaunchScreen 46 | UIMainStoryboardFile 47 | Main 48 | UIRequiredDeviceCapabilities 49 | 50 | armv7 51 | 52 | UISupportedInterfaceOrientations 53 | 54 | UIInterfaceOrientationPortrait 55 | 56 | UISupportedInterfaceOrientations~ipad 57 | 58 | UIInterfaceOrientationPortrait 59 | UIInterfaceOrientationPortraitUpsideDown 60 | UIInterfaceOrientationLandscapeLeft 61 | UIInterfaceOrientationLandscapeRight 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Example/Scene/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // SwiftyFitsize_Scene 4 | // 5 | // Created by LinXunFeng on 2021/8/25. 6 | // Copyright © 2021 CocoaPods. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 12 | 13 | var window: UIWindow? 14 | 15 | 16 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 17 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 18 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 19 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 20 | guard let _ = (scene as? UIWindowScene) else { return } 21 | } 22 | 23 | func sceneDidDisconnect(_ scene: UIScene) { 24 | // Called as the scene is being released by the system. 25 | // This occurs shortly after the scene enters the background, or when its session is discarded. 26 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 27 | // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). 28 | } 29 | 30 | func sceneDidBecomeActive(_ scene: UIScene) { 31 | // Called when the scene has moved from an inactive state to an active state. 32 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 33 | } 34 | 35 | func sceneWillResignActive(_ scene: UIScene) { 36 | // Called when the scene will move from an active state to an inactive state. 37 | // This may occur due to temporary interruptions (ex. an incoming phone call). 38 | } 39 | 40 | func sceneWillEnterForeground(_ scene: UIScene) { 41 | // Called as the scene transitions from the background to the foreground. 42 | // Use this method to undo the changes made on entering the background. 43 | } 44 | 45 | func sceneDidEnterBackground(_ scene: UIScene) { 46 | // Called as the scene transitions from the foreground to the background. 47 | // Use this method to save data, release shared resources, and store enough scene-specific state information 48 | // to restore the scene back to its current state. 49 | } 50 | 51 | 52 | } 53 | 54 | -------------------------------------------------------------------------------- /Example/Scene/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // SwiftyFitsize_Scene 4 | // 5 | // Created by LinXunFeng on 2021/8/25. 6 | // Copyright © 2021 CocoaPods. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import SwiftyFitsize 11 | import SnapKit 12 | 13 | class ViewController: UIViewController { 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | 18 | view.backgroundColor = UIColor.white 19 | 20 | print("view.frame.width~:\(view.frame.width) => \(view.frame.width~)") 21 | print("view.frame.height∣-:\(view.frame.height) => \((view.frame.height)∣-)") 22 | print(self.view.frame~) 23 | 24 | self.view.backgroundColor = .white 25 | 26 | // 设计稿上的大小 27 | let refHeight: CGFloat = 667 28 | 29 | let view1 = UIView() 30 | let view2 = UIView() 31 | let view3 = UIView() 32 | let view4 = UIView() 33 | let view5 = UIView() 34 | let view6 = UIView() 35 | view1.backgroundColor = .red 36 | view2.backgroundColor = .blue 37 | view3.backgroundColor = .orange 38 | view4.backgroundColor = .green 39 | view5.backgroundColor = .purple 40 | view6.backgroundColor = .systemPink 41 | self.view.addSubview(view1) 42 | self.view.addSubview(view2) 43 | self.view.addSubview(view3) 44 | self.view.addSubview(view4) 45 | self.view.addSubview(view5) 46 | self.view.addSubview(view6) 47 | 48 | let topMargin: CGFloat = SwiftyFitsize.Config.Device.getSafeAreaTopMargin() 49 | 50 | // ∣ 和 ∥ 的区别,就是 ~ 和 ≈ 的区别一样 51 | // ∣ 在ipad上会乘上一个系数,使在ipad上尺寸不会显得太大,请自行判断是否需要 52 | // ∥ 则不会 53 | 54 | // 适配安全区域内的高度,请使用 ∣= or ∥= 55 | view1.snp.makeConstraints { make in 56 | make.top.equalToSuperview().offset(topMargin) 57 | make.height.equalTo(refHeight∥= * 0.5) 58 | make.width.equalTo(50) 59 | make.left.equalTo(5) 60 | } 61 | view2.snp.makeConstraints { make in 62 | make.width.height.equalTo(view1) 63 | make.left.equalTo(view1).offset(2) 64 | make.top.equalTo(view1.snp.bottom) 65 | } 66 | 67 | // 适配全屏高度,请使用 ∣ or ∥ 68 | view3.snp.makeConstraints { make in 69 | make.left.equalTo(view1.snp.right).offset(8) 70 | make.top.equalToSuperview() 71 | make.width.equalTo(view1) 72 | make.height.equalTo(refHeight∥ * 0.5) 73 | } 74 | view4.snp.makeConstraints { make in 75 | make.top.equalTo(view3.snp.bottom) 76 | make.width.height.equalTo(view3) 77 | make.left.equalTo(view3).offset(2) 78 | } 79 | 80 | // 适配安全区域内的高度,请使用 ∣- or ∥- 81 | view5.snp.makeConstraints { make in 82 | make.top.equalToSuperview().offset(topMargin) 83 | make.right.equalToSuperview().offset(-5) 84 | make.width.equalTo(view1) 85 | make.height.equalTo(refHeight∥- * 0.5) 86 | } 87 | view6.snp.makeConstraints { make in 88 | make.top.equalTo(view5.snp.bottom) 89 | make.width.height.equalTo(view5) 90 | make.left.equalTo(view5).offset(-2) 91 | } 92 | } 93 | } 94 | 95 | -------------------------------------------------------------------------------- /Example/Swift/SwiftyFitsize/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // SwiftyFitsize 4 | // 5 | // Created by LinXunFeng on 10/17/2018. 6 | // Copyright (c) 2018 LinXunFeng. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import SwiftyFitsize 11 | 12 | @UIApplicationMain 13 | class AppDelegate: UIResponder, UIApplicationDelegate { 14 | 15 | var window: UIWindow? 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 18 | 19 | // SwiftyFitsize.reference(width: 414, iPadFitMultiple: 0.5) 20 | // SwiftyFitsize.reference(width: 375, calcResultType: .round) // 全局配置计算结果为四舍五入 21 | 22 | return true 23 | } 24 | } 25 | 26 | -------------------------------------------------------------------------------- /Example/Swift/SwiftyFitsize/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 25 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /Example/Swift/SwiftyFitsize/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /Example/Swift/SwiftyFitsize/FitsizeView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FitsizeView.swift 3 | // SwiftyFitsize_Example 4 | // 5 | // Created by LinXunFeng on 2018/11/1. 6 | // Copyright © 2018 CocoaPods. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class FitsizeView: UIView { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Example/Swift/SwiftyFitsize/FitsizeView.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /Example/Swift/SwiftyFitsize/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ios-marketing", 45 | "size" : "1024x1024", 46 | "scale" : "1x" 47 | } 48 | ], 49 | "info" : { 50 | "version" : 1, 51 | "author" : "xcode" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Example/Swift/SwiftyFitsize/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Example/Swift/SwiftyFitsize/Images.xcassets/lxf.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "lxf@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Example/Swift/SwiftyFitsize/Images.xcassets/lxf.imageset/lxf@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LinXunFeng/SwiftyFitsize/ec3186506cade6980087f77ed9d8128d5835e740/Example/Swift/SwiftyFitsize/Images.xcassets/lxf.imageset/lxf@2x.png -------------------------------------------------------------------------------- /Example/Swift/SwiftyFitsize/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /Example/Swift/SwiftyFitsize/LandscapeViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LandscapeViewController.swift 3 | // SwiftyFitsize_Swift 4 | // 5 | // Created by LinXunFeng on 2020/12/3. 6 | // Copyright © 2020 LinXunFeng. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import SnapKit 11 | import SwiftyFitsize 12 | 13 | class LandscapeViewController: UIViewController { 14 | 15 | fileprivate let fitLabel1 : UILabel = { 16 | let v = UILabel() 17 | let fontSize: CGFloat = 45 18 | v.font = UIFont(name: "PingFangSC-Regular", size: fontSize)!∥- 19 | v.text = "https://github.com/LinXunFeng" 20 | return v 21 | }() 22 | 23 | fileprivate let fitLabel2 : UILabel = { 24 | let v = UILabel() 25 | let fontSize: CGFloat = 45 26 | v.font = UIFont(name: "PingFangSC-Regular", size: fontSize)!∥= 27 | v.text = "https://github.com/LinXunFeng" 28 | return v 29 | }() 30 | 31 | override func viewDidLoad() { 32 | super.viewDidLoad() 33 | self.view.backgroundColor = .white 34 | 35 | // 设计稿上的大小 36 | let refWidth: CGFloat = 667 37 | 38 | let view1 = UIView() 39 | let view2 = UIView() 40 | let view3 = UIView() 41 | let view4 = UIView() 42 | let view5 = UIView() 43 | let view6 = UIView() 44 | view1.backgroundColor = .red 45 | view2.backgroundColor = .blue 46 | view3.backgroundColor = .orange 47 | view4.backgroundColor = .green 48 | view5.backgroundColor = .purple 49 | view6.backgroundColor = .systemPink 50 | self.view.addSubview(view1) 51 | self.view.addSubview(view2) 52 | self.view.addSubview(view3) 53 | self.view.addSubview(view4) 54 | self.view.addSubview(view5) 55 | self.view.addSubview(view6) 56 | self.view.addSubview(fitLabel1) 57 | self.view.addSubview(fitLabel2) 58 | 59 | var leftMargin: CGFloat = 0 60 | if #available(iOS 11.0, *) { 61 | // print(UIApplication.shared.keyWindow?.safeAreaInsets) 62 | leftMargin = UIApplication.shared.keyWindow?.safeAreaInsets.left ?? 0 63 | } 64 | var leftBangMargin: CGFloat = 0 65 | if UIApplication.shared.statusBarOrientation == .landscapeRight { 66 | leftBangMargin = leftMargin 67 | } 68 | 69 | 70 | // ∣ 和 ∥ 的区别,就是 ~ 和 ≈ 的区别一样 71 | // ∣ 在ipad上会乘上一个系数,使在ipad上尺寸不会显得太大,请自行判断是否需要 72 | // ∥ 则不会 73 | 74 | // 适配安全区域内的高度,请使用 ∣= or ∥= 75 | let isIPad = SwiftyFitsize.Config.Device.isIPad 76 | let view1TopMargin = isIPad ? 100 : 50 77 | view1.snp.makeConstraints { make in 78 | make.top.equalToSuperview().offset(view1TopMargin) 79 | make.height.equalTo(20) 80 | make.left.equalTo(0).offset(leftMargin) 81 | make.width.equalTo(refWidth∥= * 0.5) 82 | // make.width.equalTo(SwiftyFitsize.fit(size: refWidth, fitType: .flexibleSafeAreaCenterHeight, referenceHeight: 667) * 0.5) 83 | } 84 | view2.snp.makeConstraints { make in 85 | make.width.height.equalTo(view1) 86 | make.left.equalTo(view1.snp.right) 87 | make.top.equalTo(view1).offset(2) 88 | } 89 | 90 | // 适配全屏高度,请使用 ∣ or ∥ 91 | view3.snp.makeConstraints { make in 92 | make.left.equalToSuperview() 93 | make.top.equalTo(view1.snp.bottom).offset(8) 94 | make.height.equalTo(view1) 95 | make.width.equalTo(refWidth∥ * 0.5) 96 | // make.width.equalTo(SwiftyFitsize.fit(size: refWidth, fitType: .flexibleHeight, referenceHeight: 667) * 0.5) 97 | } 98 | view4.snp.makeConstraints { make in 99 | make.top.equalTo(view3).offset(2) 100 | make.width.height.equalTo(view3) 101 | make.left.equalTo(view3.snp.right) 102 | } 103 | 104 | // 适配安全区域内的高度,请使用 ∣- or ∥- 105 | view5.snp.makeConstraints { make in 106 | make.left.equalToSuperview().offset(leftBangMargin) 107 | make.height.equalTo(view1) 108 | make.width.equalTo(refWidth∥- * 0.5) 109 | // make.width.equalTo(SwiftyFitsize.fit(size: refWidth, fitType: .flexibleSafeAreaWithoutTopHeight, referenceHeight: 667) * 0.5) 110 | make.bottom.equalTo(view6.snp.bottom).offset(-2) 111 | } 112 | view6.snp.makeConstraints { make in 113 | make.bottom.equalToSuperview().offset(-30) 114 | make.width.height.equalTo(view5) 115 | make.left.equalTo(view5.snp.right) 116 | } 117 | 118 | fitLabel1.snp.makeConstraints { make in 119 | make.top.equalTo(view3.snp.bottom).offset(8) 120 | make.left.equalToSuperview().offset(leftBangMargin) 121 | } 122 | fitLabel2.snp.makeConstraints { make in 123 | make.top.equalTo(fitLabel1.snp.bottom).offset(8) 124 | make.left.equalTo(view1) 125 | } 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /Example/Swift/SwiftyFitsize/PortraitViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PortraitViewController.swift 3 | // SwiftyFitsize_Swift 4 | // 5 | // Created by LinXunFeng on 2020/12/5. 6 | // Copyright © 2020 LinXunFeng. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import SnapKit 11 | import SwiftyFitsize 12 | 13 | class PortraitViewController: UIViewController { 14 | 15 | override func viewWillAppear(_ animated: Bool) { 16 | self.navigationController?.setNavigationBarHidden(true, animated: true) 17 | } 18 | 19 | override func viewWillDisappear(_ animated: Bool) { 20 | self.navigationController?.setNavigationBarHidden(false, animated: true) 21 | } 22 | 23 | override func viewDidLoad() { 24 | super.viewDidLoad() 25 | self.view.backgroundColor = .white 26 | let popBtn = UIButton() 27 | popBtn.setTitle("POP", for: .normal) 28 | popBtn.backgroundColor = .black 29 | popBtn.addTarget(self, action: #selector(popBtnClick), for: .touchUpInside) 30 | self.view.addSubview(popBtn) 31 | popBtn.snp.makeConstraints { make in 32 | make.centerX.centerY.equalToSuperview() 33 | make.width.equalTo(80) 34 | make.height.equalTo(50) 35 | } 36 | 37 | // 设计稿上的大小 38 | let refHeight: CGFloat = 667 39 | 40 | let view1 = UIView() 41 | let view2 = UIView() 42 | let view3 = UIView() 43 | let view4 = UIView() 44 | let view5 = UIView() 45 | let view6 = UIView() 46 | view1.backgroundColor = .red 47 | view2.backgroundColor = .blue 48 | view3.backgroundColor = .orange 49 | view4.backgroundColor = .green 50 | view5.backgroundColor = .purple 51 | view6.backgroundColor = .systemPink 52 | self.view.addSubview(view1) 53 | self.view.addSubview(view2) 54 | self.view.addSubview(view3) 55 | self.view.addSubview(view4) 56 | self.view.addSubview(view5) 57 | self.view.addSubview(view6) 58 | 59 | let topMargin: CGFloat = SwiftyFitsize.Config.Device.getSafeAreaTopMargin() 60 | let bottomMargin: CGFloat = SwiftyFitsize.Config.Device.getSafeAreaBottomMargin() 61 | print("bottomMargin -- \(bottomMargin)") 62 | 63 | // ∣ 和 ∥ 的区别,就是 ~ 和 ≈ 的区别一样 64 | // ∣ 在ipad上会乘上一个系数,使在ipad上尺寸不会显得太大,请自行判断是否需要 65 | // ∥ 则不会 66 | 67 | // 适配安全区域内的高度,请使用 ∣= or ∥= 68 | view1.snp.makeConstraints { make in 69 | make.top.equalToSuperview().offset(topMargin) 70 | make.height.equalTo(refHeight∥= * 0.5) 71 | // make.height.equalTo(SwiftyFitsize.fit(size: refHeight, fitType: .flexibleSafeAreaCenterHeight, referenceHeight: 667) * 0.5) 72 | // make.height.equalTo(SwiftyFitsize.fit(size: refHeight, fitType: .forceSafeAreaCenterHeight, referenceHeight: 667) * 0.5) 73 | make.width.equalTo(50) 74 | make.left.equalTo(5) 75 | } 76 | view2.snp.makeConstraints { make in 77 | make.width.height.equalTo(view1) 78 | make.left.equalTo(view1).offset(2) 79 | make.top.equalTo(view1.snp.bottom) 80 | } 81 | 82 | // 适配全屏高度,请使用 ∣ or ∥ 83 | view3.snp.makeConstraints { make in 84 | make.left.equalTo(view1.snp.right).offset(8) 85 | make.top.equalToSuperview() 86 | make.width.equalTo(view1) 87 | make.height.equalTo(refHeight∥ * 0.5) 88 | // make.height.equalTo(SwiftyFitsize.fit(size: refHeight, fitType: .flexibleHeight, referenceHeight: 667) * 0.5) 89 | // make.height.equalTo(SwiftyFitsize.fit(size: refHeight, fitType: .forceHeight, referenceHeight: 667) * 0.5) 90 | // make.height.equalTo(SwiftyFitsize.fit(size: refHeight, fitType: .flexibleHeight, referenceHeight: 667) * 0.5) 91 | } 92 | view4.snp.makeConstraints { make in 93 | make.top.equalTo(view3.snp.bottom) 94 | make.width.height.equalTo(view3) 95 | make.left.equalTo(view3).offset(2) 96 | } 97 | 98 | // 适配安全区域内的高度,请使用 ∣- or ∥- 99 | view5.snp.makeConstraints { make in 100 | make.top.equalToSuperview().offset(topMargin) 101 | make.right.equalToSuperview().offset(-5) 102 | make.width.equalTo(view1) 103 | make.height.equalTo(refHeight∥- * 0.5) 104 | // make.height.equalTo(SwiftyFitsize.fit(size: refHeight, fitType: .flexibleSafeAreaWithoutTopHeight, referenceHeight: 667) * 0.5) 105 | // make.height.equalTo(SwiftyFitsize.fit(size: refHeight, fitType: .forceSafeAreaWithoutTopHeight, referenceHeight: 667) * 0.5) 106 | } 107 | view6.snp.makeConstraints { make in 108 | make.top.equalTo(view5.snp.bottom) 109 | make.width.height.equalTo(view5) 110 | make.left.equalTo(view5).offset(-2) 111 | } 112 | } 113 | 114 | @objc func popBtnClick() { 115 | self.navigationController?.popViewController(animated: true) 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /Example/Swift/SwiftyFitsize/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // SwiftyFitsize 4 | // 5 | // Created by LinXunFeng on 10/17/2018. 6 | // Copyright (c) 2018 LinXunFeng. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import SwiftyFitsize 11 | import SnapKit 12 | 13 | struct Metric { 14 | static let tableViewLeftRightMargin: CGFloat = 10 15 | static let tableViewTopMargin: CGFloat = 10 16 | static let tableViewHeight: CGFloat = Fit.$width(30) // 去掉左右边距后进行适配的值 17 | static let rowViewTopMargin: CGFloat = 5 18 | static let rowViewHeight: CGFloat = tableViewHeight - rowViewTopMargin * 2 19 | static let rowLeftViewWidth: CGFloat = Fit.$width(177.5) 20 | static let rowCenterViewWidth: CGFloat = Fit.$width(100.5) 21 | static let rowRightViewWidth: CGFloat = Fit.$width(77) 22 | } 23 | 24 | struct Fit { 25 | // @WrappedSwiftyFitsize(fitType: .flexibleWidth, reduceValue: Metric.tableViewLeftRightMargin) 26 | // @WrappedSwiftyFitsize(reduceValue: Metric.tableViewLeftRightMargin * 2, calcResultType: .round) // calcResultType: .round 计算结果四舍五入,不传则按全局配置的来 27 | @WrappedSwiftyFitsize(reduceValue: Metric.tableViewLeftRightMargin * 2) // fitType 默认值是 .flexibleWidth 28 | static var width: CGFloat = 375 29 | // 375是初始化值,没有特殊意义,只为调用 Fit.width 时可以取到值,如果用不到 Fit.width 的值可以不进行初始化 30 | 31 | // @WrappedSwiftyFitsize(fitType: .flexibleWidth, referenceWidth: 375, calcResultType: .raw) 32 | // static var testW: CGFloat = 375 33 | // 34 | // @WrappedSwiftyFitsize(fitType: .flexibleHeight, referenceHeight: 667, calcResultType: .raw) 35 | // static var testH: CGFloat = 667 36 | 37 | @WrappedSwiftyFitsize(fitType: .flexibleWidth, referenceWidth: 414, calcResultType: .raw) 38 | static var testW: CGFloat = 375 39 | 40 | @WrappedSwiftyFitsize(fitType: .flexibleSafeAreaWithoutTopHeight, referenceHeight: 896, isIPhoneXSeriesHeight: true, calcResultType: .raw) 41 | static var testH: CGFloat = 896 42 | } 43 | 44 | class ViewController: UIViewController { 45 | 46 | fileprivate let fitLabel : UILabel = { 47 | let v = UILabel() 48 | v.font = UIFont.boldSystemFont(ofSize: 25)~ 49 | v.text = "https://github.com/LinXunFeng" 50 | return v 51 | }() 52 | 53 | fileprivate let redView : UIView = { 54 | let v = UIView() 55 | v.backgroundColor = .red 56 | return v 57 | }() 58 | 59 | override func viewDidLoad() { 60 | super.viewDidLoad() 61 | 62 | /// 移除指定大小后的适配 63 | self.testFitWidthForReduceSize() 64 | 65 | let portraitBtn = UIButton() 66 | portraitBtn.setTitle("竖屏后点我", for: .normal) 67 | portraitBtn.backgroundColor = .brown 68 | portraitBtn.addTarget(self, action: #selector(portraitBtnClick), for: .touchUpInside) 69 | 70 | let landscapeBtn = UIButton() 71 | landscapeBtn.setTitle("横屏后点我", for: .normal) 72 | landscapeBtn.backgroundColor = .brown 73 | landscapeBtn.addTarget(self, action: #selector(landscapeBtnClick), for: .touchUpInside) 74 | 75 | self.view.addSubview(fitLabel) 76 | self.view.addSubview(redView) 77 | self.view.addSubview(portraitBtn) 78 | self.view.addSubview(landscapeBtn) 79 | 80 | fitLabel.sizeToFit() 81 | let fitLabelX: CGFloat = 15 82 | let fitLabelY: CGFloat = 100 83 | var frame = fitLabel.frame 84 | frame.origin.x = fitLabelX~ 85 | frame.origin.y = fitLabelY~ 86 | fitLabel.frame = frame 87 | 88 | let redViewFrame = CGRect( 89 | x: fitLabelX, 90 | y: fitLabelY + 50, 91 | width: 100, 92 | height: 100) 93 | redView.frame = redViewFrame~ 94 | 95 | let tableView = UIView() 96 | tableView.backgroundColor = .darkGray 97 | self.view.addSubview(tableView) 98 | tableView.snp.makeConstraints { make in 99 | make.left.equalToSuperview().offset(Metric.tableViewLeftRightMargin) 100 | make.right.equalToSuperview().offset(-Metric.tableViewLeftRightMargin) 101 | make.top.equalTo(self.redView.snp.bottom).offset(Metric.tableViewTopMargin) 102 | make.height.equalTo(Metric.tableViewHeight) 103 | } 104 | let rowLeftView = UIView() 105 | rowLeftView.backgroundColor = .red 106 | tableView.addSubview(rowLeftView) 107 | rowLeftView.snp.makeConstraints { make in 108 | make.width.equalTo(Metric.rowLeftViewWidth) 109 | make.height.equalTo(Metric.rowViewHeight) 110 | make.top.equalTo(Metric.rowViewTopMargin) 111 | make.left.equalToSuperview() 112 | } 113 | let rowCenterView = UIView() 114 | rowCenterView.backgroundColor = .green 115 | tableView.addSubview(rowCenterView) 116 | rowCenterView.snp.makeConstraints { make in 117 | make.width.equalTo(Metric.rowCenterViewWidth) 118 | make.height.top.equalTo(rowLeftView) 119 | make.left.equalTo(rowLeftView.snp.right) 120 | } 121 | let rowRightView = UIView() 122 | rowRightView.backgroundColor = .blue 123 | tableView.addSubview(rowRightView) 124 | rowRightView.snp.makeConstraints { make in 125 | make.width.equalTo(Metric.rowRightViewWidth) 126 | make.height.top.equalTo(rowLeftView) 127 | make.left.equalTo(rowCenterView.snp.right) 128 | } 129 | 130 | if let fitsizeView = UINib(nibName: String(describing: FitsizeView.self), bundle: nil).instantiate(withOwner: nil, options: nil).first as? FitsizeView { 131 | self.view.addSubview(fitsizeView) 132 | fitsizeView.frame = CGRect(x: 0, y: redViewFrame~.maxY + Metric.tableViewHeight, width: 328~, height: 298~) 133 | } 134 | 135 | portraitBtn.snp.makeConstraints { make in 136 | make.left.equalTo(redView.snp.right).offset(5) 137 | make.height.equalTo(40~) 138 | make.width.equalTo(120) 139 | make.top.equalTo(redView) 140 | } 141 | landscapeBtn.snp.makeConstraints { make in 142 | make.left.width.height.equalTo(portraitBtn) 143 | make.top.equalTo(portraitBtn.snp.bottom).offset(10) 144 | } 145 | } 146 | 147 | @objc func portraitBtnClick() { 148 | let vc = PortraitViewController() 149 | self.navigationController?.pushViewController(vc, animated: true) 150 | } 151 | 152 | @objc func landscapeBtnClick() { 153 | let vc = LandscapeViewController() 154 | self.navigationController?.pushViewController(vc, animated: true) 155 | } 156 | } 157 | 158 | extension ViewController { 159 | /// 移除指定大小后的适配 160 | func testFitWidthForReduceSize() { 161 | print("默认适配的宽度: \(Fit.width)") 162 | 163 | // 移除指定尺寸后的适配,调用方式: 164 | // 以下都是以适配 tableView 为例,移除 tableView 左右两侧固定的边距,以剩余的宽度来做适配 165 | 166 | // 方式一:先赋值再取值 167 | // 将 20 进行适配 168 | Fit.width = 20 169 | print("适配后的值 -- \(Fit.width)") 170 | 171 | // 方式二:使用 $ 将 width 当方法用,传入待适配的值 172 | // 将 30 进行适配 173 | let aVal = Fit.$width(30) 174 | print("适配后的值 aVal -- \(aVal)") 175 | 176 | // 方式三:调用 SwiftyFitsize.fit 方法 177 | let bVal = SwiftyFitsize.fit( 178 | size: 40, 179 | fitType: .flexibleWidth, 180 | reduceValue: Metric.tableViewLeftRightMargin * 2 181 | ) 182 | print("适配后的值 bVal -- \(bVal)") 183 | 184 | print("============") 185 | print("指定不同的calcResultType,适配后的值") 186 | let calcVal: CGFloat = 36 187 | // 其它 188 | let cVal = SwiftyFitsize.fit( 189 | size: calcVal, 190 | fitType: .flexibleWidth, 191 | reduceValue: Metric.tableViewLeftRightMargin * 2, 192 | calcResultType: .raw 193 | ) 194 | print("适配后的值 cVal -- \(cVal)") 195 | 196 | let dVal = SwiftyFitsize.fit( 197 | size: calcVal, 198 | fitType: .flexibleWidth, 199 | reduceValue: Metric.tableViewLeftRightMargin * 2, 200 | calcResultType: .round 201 | ) 202 | print("适配后的值 dVal -- \(dVal)") 203 | 204 | let eVal = SwiftyFitsize.fit( 205 | size: calcVal, 206 | fitType: .flexibleWidth, 207 | reduceValue: Metric.tableViewLeftRightMargin * 2, 208 | calcResultType: .oneDecimalPlace 209 | ) 210 | print("适配后的值 eVal -- \(eVal)") 211 | print("============") 212 | 213 | print("safeAreaInsets -- \(SwiftyFitsize.Config.Device.getSafeAreaInsets())") 214 | 215 | Fit.testW = 414 216 | print("testW -- \(Fit.testW)") 217 | 218 | Fit.testH = 896 219 | print("testH -- \(Fit.testH)") 220 | } 221 | } 222 | 223 | -------------------------------------------------------------------------------- /Example/Swift/Tests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Example/Swift/Tests/Tests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import SwiftyFitsize 3 | 4 | class Tests: XCTestCase { 5 | 6 | override func setUp() { 7 | super.setUp() 8 | // Put setup code here. This method is called before the invocation of each test method in the class. 9 | } 10 | 11 | override func tearDown() { 12 | // Put teardown code here. This method is called after the invocation of each test method in the class. 13 | super.tearDown() 14 | } 15 | 16 | func testExample() { 17 | // This is an example of a functional test case. 18 | XCTAssert(true, "Pass") 19 | } 20 | 21 | func testPerformanceExample() { 22 | // This is an example of a performance test case. 23 | self.measure() { 24 | // Put the code you want to measure the time of here. 25 | } 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /Example/SwiftyFitsize.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/SwiftyFitsize.xcodeproj/xcshareddata/xcschemes/SwiftyFitsize-Swift.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 67 | 68 | 78 | 80 | 86 | 87 | 88 | 89 | 90 | 91 | 97 | 99 | 105 | 106 | 107 | 108 | 110 | 111 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /Example/SwiftyFitsizePackage.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 52; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 607FACEC1AFB9204008FA782 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* Tests.swift */; }; 11 | FD46E4582864BCD400C80FDF /* SwiftyFitsize in Frameworks */ = {isa = PBXBuildFile; productRef = FD46E4572864BCD400C80FDF /* SwiftyFitsize */; }; 12 | FD46E45E2864C3D000C80FDF /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = FD46E45D2864C3D000C80FDF /* SnapKit */; }; 13 | FD58D9A825792722003270C8 /* LandscapeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD58D9A725792722003270C8 /* LandscapeViewController.swift */; }; 14 | FD58D9FA257B4EB0003270C8 /* PortraitViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD58D9F9257B4EB0003270C8 /* PortraitViewController.swift */; }; 15 | FD7BFAAC2866F09F002B2F01 /* SwiftyFitsize in Frameworks */ = {isa = PBXBuildFile; productRef = FD7BFAAB2866F09F002B2F01 /* SwiftyFitsize */; }; 16 | FD7BFAAE2866F0AA002B2F01 /* SwiftyFitsize in Frameworks */ = {isa = PBXBuildFile; productRef = FD7BFAAD2866F0AA002B2F01 /* SwiftyFitsize */; }; 17 | FD7BFAB02866F76D002B2F01 /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = FD7BFAAF2866F76D002B2F01 /* SnapKit */; }; 18 | FDC4F7B626D6901F002D67AE /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FDC4F7B526D6901F002D67AE /* AppDelegate.swift */; }; 19 | FDC4F7B826D6901F002D67AE /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FDC4F7B726D6901F002D67AE /* SceneDelegate.swift */; }; 20 | FDC4F7BA26D6901F002D67AE /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FDC4F7B926D6901F002D67AE /* ViewController.swift */; }; 21 | FDC4F7BD26D6901F002D67AE /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FDC4F7BB26D6901F002D67AE /* Main.storyboard */; }; 22 | FDC4F7BF26D69021002D67AE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FDC4F7BE26D69021002D67AE /* Assets.xcassets */; }; 23 | FDC4F7C226D69021002D67AE /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FDC4F7C026D69021002D67AE /* LaunchScreen.storyboard */; }; 24 | FDD73CF6219D053F00CF24B1 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = FDD73CF5219D053F00CF24B1 /* AppDelegate.m */; }; 25 | FDD73CF9219D053F00CF24B1 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FDD73CF8219D053F00CF24B1 /* ViewController.m */; }; 26 | FDD73CFC219D053F00CF24B1 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FDD73CFA219D053F00CF24B1 /* Main.storyboard */; }; 27 | FDD73CFE219D054000CF24B1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FDD73CFD219D054000CF24B1 /* Assets.xcassets */; }; 28 | FDD73D01219D054000CF24B1 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FDD73CFF219D054000CF24B1 /* LaunchScreen.storyboard */; }; 29 | FDD73D04219D054000CF24B1 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = FDD73D03219D054000CF24B1 /* main.m */; }; 30 | FDD73D0E219D054000CF24B1 /* SwiftyFitsize_OCTests.m in Sources */ = {isa = PBXBuildFile; fileRef = FDD73D0D219D054000CF24B1 /* SwiftyFitsize_OCTests.m */; }; 31 | FDD73D19219D054000CF24B1 /* SwiftyFitsize_OCUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = FDD73D18219D054000CF24B1 /* SwiftyFitsize_OCUITests.m */; }; 32 | FDD73D45219D077C00CF24B1 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FDD73D3B219D077C00CF24B1 /* ViewController.swift */; }; 33 | FDD73D46219D077C00CF24B1 /* FitsizeView.xib in Resources */ = {isa = PBXBuildFile; fileRef = FDD73D3C219D077C00CF24B1 /* FitsizeView.xib */; }; 34 | FDD73D47219D077C00CF24B1 /* FitsizeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FDD73D3D219D077C00CF24B1 /* FitsizeView.swift */; }; 35 | FDD73D48219D077C00CF24B1 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = FDD73D3E219D077C00CF24B1 /* LaunchScreen.xib */; }; 36 | FDD73D49219D077C00CF24B1 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FDD73D40219D077C00CF24B1 /* Main.storyboard */; }; 37 | FDD73D4A219D077C00CF24B1 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FDD73D42219D077C00CF24B1 /* Images.xcassets */; }; 38 | FDD73D4B219D077C00CF24B1 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FDD73D43219D077C00CF24B1 /* AppDelegate.swift */; }; 39 | /* End PBXBuildFile section */ 40 | 41 | /* Begin PBXContainerItemProxy section */ 42 | 607FACE61AFB9204008FA782 /* PBXContainerItemProxy */ = { 43 | isa = PBXContainerItemProxy; 44 | containerPortal = 607FACC81AFB9204008FA782 /* Project object */; 45 | proxyType = 1; 46 | remoteGlobalIDString = 607FACCF1AFB9204008FA782; 47 | remoteInfo = SwiftyFitsize; 48 | }; 49 | FDD73D0A219D054000CF24B1 /* PBXContainerItemProxy */ = { 50 | isa = PBXContainerItemProxy; 51 | containerPortal = 607FACC81AFB9204008FA782 /* Project object */; 52 | proxyType = 1; 53 | remoteGlobalIDString = FDD73CF1219D053F00CF24B1; 54 | remoteInfo = "SwiftyFitsize-OC"; 55 | }; 56 | FDD73D15219D054000CF24B1 /* PBXContainerItemProxy */ = { 57 | isa = PBXContainerItemProxy; 58 | containerPortal = 607FACC81AFB9204008FA782 /* Project object */; 59 | proxyType = 1; 60 | remoteGlobalIDString = FDD73CF1219D053F00CF24B1; 61 | remoteInfo = "SwiftyFitsize-OC"; 62 | }; 63 | /* End PBXContainerItemProxy section */ 64 | 65 | /* Begin PBXFileReference section */ 66 | 1F39449069E67D0AFAF81865 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = ""; }; 67 | 607FACD01AFB9204008FA782 /* SwiftyFitsize_Swift.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftyFitsize_Swift.app; sourceTree = BUILT_PRODUCTS_DIR; }; 68 | 607FACE51AFB9204008FA782 /* SwiftyFitsize_SwiftTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftyFitsize_SwiftTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 69 | 607FACEA1AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 70 | 607FACEB1AFB9204008FA782 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tests.swift; sourceTree = ""; }; 71 | BE7798381C8FED4CEF4E3272 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; }; 72 | E6F933659A20197919B99384 /* SwiftyFitsize.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = SwiftyFitsize.podspec; path = ../SwiftyFitsize.podspec; sourceTree = ""; }; 73 | FD46E44F2864B6A600C80FDF /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Package.swift; path = ../Package.swift; sourceTree = ""; }; 74 | FD46E4562864BC9800C80FDF /* SwiftyFitsize */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = SwiftyFitsize; path = ..; sourceTree = ""; }; 75 | FD58D9A725792722003270C8 /* LandscapeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LandscapeViewController.swift; sourceTree = ""; }; 76 | FD58D9F9257B4EB0003270C8 /* PortraitViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PortraitViewController.swift; sourceTree = ""; }; 77 | FDC4F7B326D6901F002D67AE /* SwiftyFitsize_Scene.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftyFitsize_Scene.app; sourceTree = BUILT_PRODUCTS_DIR; }; 78 | FDC4F7B526D6901F002D67AE /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 79 | FDC4F7B726D6901F002D67AE /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 80 | FDC4F7B926D6901F002D67AE /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 81 | FDC4F7BC26D6901F002D67AE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 82 | FDC4F7BE26D69021002D67AE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 83 | FDC4F7C126D69021002D67AE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 84 | FDC4F7C326D69021002D67AE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 85 | FDD73CF2219D053F00CF24B1 /* SwiftyFitsize_OC.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftyFitsize_OC.app; sourceTree = BUILT_PRODUCTS_DIR; }; 86 | FDD73CF4219D053F00CF24B1 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 87 | FDD73CF5219D053F00CF24B1 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 88 | FDD73CF7219D053F00CF24B1 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 89 | FDD73CF8219D053F00CF24B1 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 90 | FDD73CFB219D053F00CF24B1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 91 | FDD73CFD219D054000CF24B1 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 92 | FDD73D00219D054000CF24B1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 93 | FDD73D02219D054000CF24B1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 94 | FDD73D03219D054000CF24B1 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 95 | FDD73D09219D054000CF24B1 /* SwiftyFitsize_OCTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftyFitsize_OCTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 96 | FDD73D0D219D054000CF24B1 /* SwiftyFitsize_OCTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SwiftyFitsize_OCTests.m; sourceTree = ""; }; 97 | FDD73D0F219D054000CF24B1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 98 | FDD73D14219D054000CF24B1 /* SwiftyFitsize_OCUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftyFitsize_OCUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 99 | FDD73D18219D054000CF24B1 /* SwiftyFitsize_OCUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SwiftyFitsize_OCUITests.m; sourceTree = ""; }; 100 | FDD73D1A219D054000CF24B1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 101 | FDD73D3B219D077C00CF24B1 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 102 | FDD73D3C219D077C00CF24B1 /* FitsizeView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = FitsizeView.xib; sourceTree = ""; }; 103 | FDD73D3D219D077C00CF24B1 /* FitsizeView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FitsizeView.swift; sourceTree = ""; }; 104 | FDD73D3F219D077C00CF24B1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 105 | FDD73D41219D077C00CF24B1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 106 | FDD73D42219D077C00CF24B1 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 107 | FDD73D43219D077C00CF24B1 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 108 | FDD73D44219D077C00CF24B1 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 109 | /* End PBXFileReference section */ 110 | 111 | /* Begin PBXFrameworksBuildPhase section */ 112 | 607FACCD1AFB9204008FA782 /* Frameworks */ = { 113 | isa = PBXFrameworksBuildPhase; 114 | buildActionMask = 2147483647; 115 | files = ( 116 | FD46E4582864BCD400C80FDF /* SwiftyFitsize in Frameworks */, 117 | FD46E45E2864C3D000C80FDF /* SnapKit in Frameworks */, 118 | ); 119 | runOnlyForDeploymentPostprocessing = 0; 120 | }; 121 | 607FACE21AFB9204008FA782 /* Frameworks */ = { 122 | isa = PBXFrameworksBuildPhase; 123 | buildActionMask = 2147483647; 124 | files = ( 125 | ); 126 | runOnlyForDeploymentPostprocessing = 0; 127 | }; 128 | FDC4F7B026D6901F002D67AE /* Frameworks */ = { 129 | isa = PBXFrameworksBuildPhase; 130 | buildActionMask = 2147483647; 131 | files = ( 132 | FD7BFAAE2866F0AA002B2F01 /* SwiftyFitsize in Frameworks */, 133 | FD7BFAB02866F76D002B2F01 /* SnapKit in Frameworks */, 134 | ); 135 | runOnlyForDeploymentPostprocessing = 0; 136 | }; 137 | FDD73CEF219D053F00CF24B1 /* Frameworks */ = { 138 | isa = PBXFrameworksBuildPhase; 139 | buildActionMask = 2147483647; 140 | files = ( 141 | FD7BFAAC2866F09F002B2F01 /* SwiftyFitsize in Frameworks */, 142 | ); 143 | runOnlyForDeploymentPostprocessing = 0; 144 | }; 145 | FDD73D06219D054000CF24B1 /* Frameworks */ = { 146 | isa = PBXFrameworksBuildPhase; 147 | buildActionMask = 2147483647; 148 | files = ( 149 | ); 150 | runOnlyForDeploymentPostprocessing = 0; 151 | }; 152 | FDD73D11219D054000CF24B1 /* Frameworks */ = { 153 | isa = PBXFrameworksBuildPhase; 154 | buildActionMask = 2147483647; 155 | files = ( 156 | ); 157 | runOnlyForDeploymentPostprocessing = 0; 158 | }; 159 | /* End PBXFrameworksBuildPhase section */ 160 | 161 | /* Begin PBXGroup section */ 162 | 34268B17AF34B66E4CC55FD4 /* Frameworks */ = { 163 | isa = PBXGroup; 164 | children = ( 165 | FD46E44F2864B6A600C80FDF /* Package.swift */, 166 | ); 167 | name = Frameworks; 168 | sourceTree = ""; 169 | }; 170 | 607FACC71AFB9204008FA782 = { 171 | isa = PBXGroup; 172 | children = ( 173 | FD46E4552864BC9800C80FDF /* Packages */, 174 | 607FACF51AFB993E008FA782 /* Podspec Metadata */, 175 | FDD73D27219D05E500CF24B1 /* OC */, 176 | FDD73D25219D05C600CF24B1 /* Swift */, 177 | FDC4F7B426D6901F002D67AE /* Scene */, 178 | 607FACD11AFB9204008FA782 /* Products */, 179 | 34268B17AF34B66E4CC55FD4 /* Frameworks */, 180 | ); 181 | sourceTree = ""; 182 | }; 183 | 607FACD11AFB9204008FA782 /* Products */ = { 184 | isa = PBXGroup; 185 | children = ( 186 | 607FACD01AFB9204008FA782 /* SwiftyFitsize_Swift.app */, 187 | 607FACE51AFB9204008FA782 /* SwiftyFitsize_SwiftTests.xctest */, 188 | FDD73CF2219D053F00CF24B1 /* SwiftyFitsize_OC.app */, 189 | FDD73D09219D054000CF24B1 /* SwiftyFitsize_OCTests.xctest */, 190 | FDD73D14219D054000CF24B1 /* SwiftyFitsize_OCUITests.xctest */, 191 | FDC4F7B326D6901F002D67AE /* SwiftyFitsize_Scene.app */, 192 | ); 193 | name = Products; 194 | sourceTree = ""; 195 | }; 196 | 607FACE81AFB9204008FA782 /* Tests */ = { 197 | isa = PBXGroup; 198 | children = ( 199 | 607FACEB1AFB9204008FA782 /* Tests.swift */, 200 | 607FACE91AFB9204008FA782 /* Supporting Files */, 201 | ); 202 | path = Tests; 203 | sourceTree = ""; 204 | }; 205 | 607FACE91AFB9204008FA782 /* Supporting Files */ = { 206 | isa = PBXGroup; 207 | children = ( 208 | 607FACEA1AFB9204008FA782 /* Info.plist */, 209 | ); 210 | name = "Supporting Files"; 211 | sourceTree = ""; 212 | }; 213 | 607FACF51AFB993E008FA782 /* Podspec Metadata */ = { 214 | isa = PBXGroup; 215 | children = ( 216 | E6F933659A20197919B99384 /* SwiftyFitsize.podspec */, 217 | BE7798381C8FED4CEF4E3272 /* README.md */, 218 | 1F39449069E67D0AFAF81865 /* LICENSE */, 219 | ); 220 | name = "Podspec Metadata"; 221 | sourceTree = ""; 222 | }; 223 | FD46E4552864BC9800C80FDF /* Packages */ = { 224 | isa = PBXGroup; 225 | children = ( 226 | FD46E4562864BC9800C80FDF /* SwiftyFitsize */, 227 | ); 228 | name = Packages; 229 | sourceTree = ""; 230 | }; 231 | FDC4F7B426D6901F002D67AE /* Scene */ = { 232 | isa = PBXGroup; 233 | children = ( 234 | FDC4F7B526D6901F002D67AE /* AppDelegate.swift */, 235 | FDC4F7B726D6901F002D67AE /* SceneDelegate.swift */, 236 | FDC4F7B926D6901F002D67AE /* ViewController.swift */, 237 | FDC4F7BB26D6901F002D67AE /* Main.storyboard */, 238 | FDC4F7BE26D69021002D67AE /* Assets.xcassets */, 239 | FDC4F7C026D69021002D67AE /* LaunchScreen.storyboard */, 240 | FDC4F7C326D69021002D67AE /* Info.plist */, 241 | ); 242 | path = Scene; 243 | sourceTree = ""; 244 | }; 245 | FDD73CF3219D053F00CF24B1 /* SwiftyFitsize */ = { 246 | isa = PBXGroup; 247 | children = ( 248 | FDD73CF4219D053F00CF24B1 /* AppDelegate.h */, 249 | FDD73CF5219D053F00CF24B1 /* AppDelegate.m */, 250 | FDD73CF7219D053F00CF24B1 /* ViewController.h */, 251 | FDD73CF8219D053F00CF24B1 /* ViewController.m */, 252 | FDD73CFA219D053F00CF24B1 /* Main.storyboard */, 253 | FDD73CFD219D054000CF24B1 /* Assets.xcassets */, 254 | FDD73CFF219D054000CF24B1 /* LaunchScreen.storyboard */, 255 | FDD73D02219D054000CF24B1 /* Info.plist */, 256 | FDD73D03219D054000CF24B1 /* main.m */, 257 | ); 258 | path = SwiftyFitsize; 259 | sourceTree = ""; 260 | }; 261 | FDD73D0C219D054000CF24B1 /* Tests */ = { 262 | isa = PBXGroup; 263 | children = ( 264 | FDD73D0D219D054000CF24B1 /* SwiftyFitsize_OCTests.m */, 265 | FDD73D0F219D054000CF24B1 /* Info.plist */, 266 | ); 267 | path = Tests; 268 | sourceTree = ""; 269 | }; 270 | FDD73D17219D054000CF24B1 /* UITests */ = { 271 | isa = PBXGroup; 272 | children = ( 273 | FDD73D18219D054000CF24B1 /* SwiftyFitsize_OCUITests.m */, 274 | FDD73D1A219D054000CF24B1 /* Info.plist */, 275 | ); 276 | path = UITests; 277 | sourceTree = ""; 278 | }; 279 | FDD73D25219D05C600CF24B1 /* Swift */ = { 280 | isa = PBXGroup; 281 | children = ( 282 | FDD73D3A219D077C00CF24B1 /* SwiftyFitsize */, 283 | 607FACE81AFB9204008FA782 /* Tests */, 284 | ); 285 | path = Swift; 286 | sourceTree = ""; 287 | }; 288 | FDD73D27219D05E500CF24B1 /* OC */ = { 289 | isa = PBXGroup; 290 | children = ( 291 | FDD73CF3219D053F00CF24B1 /* SwiftyFitsize */, 292 | FDD73D0C219D054000CF24B1 /* Tests */, 293 | FDD73D17219D054000CF24B1 /* UITests */, 294 | ); 295 | path = OC; 296 | sourceTree = ""; 297 | }; 298 | FDD73D3A219D077C00CF24B1 /* SwiftyFitsize */ = { 299 | isa = PBXGroup; 300 | children = ( 301 | FDD73D3B219D077C00CF24B1 /* ViewController.swift */, 302 | FD58D9F9257B4EB0003270C8 /* PortraitViewController.swift */, 303 | FD58D9A725792722003270C8 /* LandscapeViewController.swift */, 304 | FDD73D3C219D077C00CF24B1 /* FitsizeView.xib */, 305 | FDD73D3D219D077C00CF24B1 /* FitsizeView.swift */, 306 | FDD73D3E219D077C00CF24B1 /* LaunchScreen.xib */, 307 | FDD73D40219D077C00CF24B1 /* Main.storyboard */, 308 | FDD73D42219D077C00CF24B1 /* Images.xcassets */, 309 | FDD73D43219D077C00CF24B1 /* AppDelegate.swift */, 310 | FDD73D44219D077C00CF24B1 /* Info.plist */, 311 | ); 312 | path = SwiftyFitsize; 313 | sourceTree = ""; 314 | }; 315 | /* End PBXGroup section */ 316 | 317 | /* Begin PBXNativeTarget section */ 318 | 607FACCF1AFB9204008FA782 /* SwiftyFitsize_Swift */ = { 319 | isa = PBXNativeTarget; 320 | buildConfigurationList = 607FACEF1AFB9204008FA782 /* Build configuration list for PBXNativeTarget "SwiftyFitsize_Swift" */; 321 | buildPhases = ( 322 | 607FACCC1AFB9204008FA782 /* Sources */, 323 | 607FACCD1AFB9204008FA782 /* Frameworks */, 324 | 607FACCE1AFB9204008FA782 /* Resources */, 325 | ); 326 | buildRules = ( 327 | ); 328 | dependencies = ( 329 | ); 330 | name = SwiftyFitsize_Swift; 331 | packageProductDependencies = ( 332 | FD46E4572864BCD400C80FDF /* SwiftyFitsize */, 333 | FD46E45D2864C3D000C80FDF /* SnapKit */, 334 | ); 335 | productName = SwiftyFitsize; 336 | productReference = 607FACD01AFB9204008FA782 /* SwiftyFitsize_Swift.app */; 337 | productType = "com.apple.product-type.application"; 338 | }; 339 | 607FACE41AFB9204008FA782 /* SwiftyFitsize_SwiftTests */ = { 340 | isa = PBXNativeTarget; 341 | buildConfigurationList = 607FACF21AFB9204008FA782 /* Build configuration list for PBXNativeTarget "SwiftyFitsize_SwiftTests" */; 342 | buildPhases = ( 343 | 0865B48E833D605A20E6027D /* [CP] Check Pods Manifest.lock */, 344 | 607FACE11AFB9204008FA782 /* Sources */, 345 | 607FACE21AFB9204008FA782 /* Frameworks */, 346 | 607FACE31AFB9204008FA782 /* Resources */, 347 | ); 348 | buildRules = ( 349 | ); 350 | dependencies = ( 351 | 607FACE71AFB9204008FA782 /* PBXTargetDependency */, 352 | ); 353 | name = SwiftyFitsize_SwiftTests; 354 | productName = Tests; 355 | productReference = 607FACE51AFB9204008FA782 /* SwiftyFitsize_SwiftTests.xctest */; 356 | productType = "com.apple.product-type.bundle.unit-test"; 357 | }; 358 | FDC4F7B226D6901F002D67AE /* SwiftyFitsize_Scene */ = { 359 | isa = PBXNativeTarget; 360 | buildConfigurationList = FDC4F7C626D69021002D67AE /* Build configuration list for PBXNativeTarget "SwiftyFitsize_Scene" */; 361 | buildPhases = ( 362 | FDC4F7AF26D6901F002D67AE /* Sources */, 363 | FDC4F7B026D6901F002D67AE /* Frameworks */, 364 | FDC4F7B126D6901F002D67AE /* Resources */, 365 | ); 366 | buildRules = ( 367 | ); 368 | dependencies = ( 369 | ); 370 | name = SwiftyFitsize_Scene; 371 | packageProductDependencies = ( 372 | FD7BFAAD2866F0AA002B2F01 /* SwiftyFitsize */, 373 | FD7BFAAF2866F76D002B2F01 /* SnapKit */, 374 | ); 375 | productName = SwiftyFitsize_Scene; 376 | productReference = FDC4F7B326D6901F002D67AE /* SwiftyFitsize_Scene.app */; 377 | productType = "com.apple.product-type.application"; 378 | }; 379 | FDD73CF1219D053F00CF24B1 /* SwiftyFitsize_OC */ = { 380 | isa = PBXNativeTarget; 381 | buildConfigurationList = FDD73D21219D054000CF24B1 /* Build configuration list for PBXNativeTarget "SwiftyFitsize_OC" */; 382 | buildPhases = ( 383 | FDD73CEE219D053F00CF24B1 /* Sources */, 384 | FDD73CEF219D053F00CF24B1 /* Frameworks */, 385 | FDD73CF0219D053F00CF24B1 /* Resources */, 386 | ); 387 | buildRules = ( 388 | ); 389 | dependencies = ( 390 | ); 391 | name = SwiftyFitsize_OC; 392 | packageProductDependencies = ( 393 | FD7BFAAB2866F09F002B2F01 /* SwiftyFitsize */, 394 | ); 395 | productName = "SwiftyFitsize-OC"; 396 | productReference = FDD73CF2219D053F00CF24B1 /* SwiftyFitsize_OC.app */; 397 | productType = "com.apple.product-type.application"; 398 | }; 399 | FDD73D08219D054000CF24B1 /* SwiftyFitsize_OCTests */ = { 400 | isa = PBXNativeTarget; 401 | buildConfigurationList = FDD73D22219D054000CF24B1 /* Build configuration list for PBXNativeTarget "SwiftyFitsize_OCTests" */; 402 | buildPhases = ( 403 | FDD73D05219D054000CF24B1 /* Sources */, 404 | FDD73D06219D054000CF24B1 /* Frameworks */, 405 | FDD73D07219D054000CF24B1 /* Resources */, 406 | ); 407 | buildRules = ( 408 | ); 409 | dependencies = ( 410 | FDD73D0B219D054000CF24B1 /* PBXTargetDependency */, 411 | ); 412 | name = SwiftyFitsize_OCTests; 413 | productName = "SwiftyFitsize-OCTests"; 414 | productReference = FDD73D09219D054000CF24B1 /* SwiftyFitsize_OCTests.xctest */; 415 | productType = "com.apple.product-type.bundle.unit-test"; 416 | }; 417 | FDD73D13219D054000CF24B1 /* SwiftyFitsize_OCUITests */ = { 418 | isa = PBXNativeTarget; 419 | buildConfigurationList = FDD73D23219D054000CF24B1 /* Build configuration list for PBXNativeTarget "SwiftyFitsize_OCUITests" */; 420 | buildPhases = ( 421 | FDD73D10219D054000CF24B1 /* Sources */, 422 | FDD73D11219D054000CF24B1 /* Frameworks */, 423 | FDD73D12219D054000CF24B1 /* Resources */, 424 | ); 425 | buildRules = ( 426 | ); 427 | dependencies = ( 428 | FDD73D16219D054000CF24B1 /* PBXTargetDependency */, 429 | ); 430 | name = SwiftyFitsize_OCUITests; 431 | productName = "SwiftyFitsize-OCUITests"; 432 | productReference = FDD73D14219D054000CF24B1 /* SwiftyFitsize_OCUITests.xctest */; 433 | productType = "com.apple.product-type.bundle.ui-testing"; 434 | }; 435 | /* End PBXNativeTarget section */ 436 | 437 | /* Begin PBXProject section */ 438 | 607FACC81AFB9204008FA782 /* Project object */ = { 439 | isa = PBXProject; 440 | attributes = { 441 | LastSwiftUpdateCheck = 1250; 442 | LastUpgradeCheck = 0830; 443 | ORGANIZATIONNAME = CocoaPods; 444 | TargetAttributes = { 445 | 607FACCF1AFB9204008FA782 = { 446 | CreatedOnToolsVersion = 6.3.1; 447 | LastSwiftMigration = 0900; 448 | }; 449 | 607FACE41AFB9204008FA782 = { 450 | CreatedOnToolsVersion = 6.3.1; 451 | LastSwiftMigration = 0900; 452 | TestTargetID = 607FACCF1AFB9204008FA782; 453 | }; 454 | FDC4F7B226D6901F002D67AE = { 455 | CreatedOnToolsVersion = 12.5.1; 456 | DevelopmentTeam = 2RA5LSHPUJ; 457 | ProvisioningStyle = Automatic; 458 | }; 459 | FDD73CF1219D053F00CF24B1 = { 460 | CreatedOnToolsVersion = 10.0; 461 | LastSwiftMigration = 1000; 462 | ProvisioningStyle = Automatic; 463 | }; 464 | FDD73D08219D054000CF24B1 = { 465 | CreatedOnToolsVersion = 10.0; 466 | ProvisioningStyle = Automatic; 467 | TestTargetID = FDD73CF1219D053F00CF24B1; 468 | }; 469 | FDD73D13219D054000CF24B1 = { 470 | CreatedOnToolsVersion = 10.0; 471 | ProvisioningStyle = Automatic; 472 | TestTargetID = FDD73CF1219D053F00CF24B1; 473 | }; 474 | }; 475 | }; 476 | buildConfigurationList = 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "SwiftyFitsizePackage" */; 477 | compatibilityVersion = "Xcode 3.2"; 478 | developmentRegion = English; 479 | hasScannedForEncodings = 0; 480 | knownRegions = ( 481 | English, 482 | en, 483 | Base, 484 | ); 485 | mainGroup = 607FACC71AFB9204008FA782; 486 | packageReferences = ( 487 | FD46E45C2864C3D000C80FDF /* XCRemoteSwiftPackageReference "SnapKit" */, 488 | ); 489 | productRefGroup = 607FACD11AFB9204008FA782 /* Products */; 490 | projectDirPath = ""; 491 | projectRoot = ""; 492 | targets = ( 493 | 607FACCF1AFB9204008FA782 /* SwiftyFitsize_Swift */, 494 | 607FACE41AFB9204008FA782 /* SwiftyFitsize_SwiftTests */, 495 | FDD73CF1219D053F00CF24B1 /* SwiftyFitsize_OC */, 496 | FDD73D08219D054000CF24B1 /* SwiftyFitsize_OCTests */, 497 | FDD73D13219D054000CF24B1 /* SwiftyFitsize_OCUITests */, 498 | FDC4F7B226D6901F002D67AE /* SwiftyFitsize_Scene */, 499 | ); 500 | }; 501 | /* End PBXProject section */ 502 | 503 | /* Begin PBXResourcesBuildPhase section */ 504 | 607FACCE1AFB9204008FA782 /* Resources */ = { 505 | isa = PBXResourcesBuildPhase; 506 | buildActionMask = 2147483647; 507 | files = ( 508 | FDD73D49219D077C00CF24B1 /* Main.storyboard in Resources */, 509 | FDD73D4A219D077C00CF24B1 /* Images.xcassets in Resources */, 510 | FDD73D48219D077C00CF24B1 /* LaunchScreen.xib in Resources */, 511 | FDD73D46219D077C00CF24B1 /* FitsizeView.xib in Resources */, 512 | ); 513 | runOnlyForDeploymentPostprocessing = 0; 514 | }; 515 | 607FACE31AFB9204008FA782 /* Resources */ = { 516 | isa = PBXResourcesBuildPhase; 517 | buildActionMask = 2147483647; 518 | files = ( 519 | ); 520 | runOnlyForDeploymentPostprocessing = 0; 521 | }; 522 | FDC4F7B126D6901F002D67AE /* Resources */ = { 523 | isa = PBXResourcesBuildPhase; 524 | buildActionMask = 2147483647; 525 | files = ( 526 | FDC4F7C226D69021002D67AE /* LaunchScreen.storyboard in Resources */, 527 | FDC4F7BF26D69021002D67AE /* Assets.xcassets in Resources */, 528 | FDC4F7BD26D6901F002D67AE /* Main.storyboard in Resources */, 529 | ); 530 | runOnlyForDeploymentPostprocessing = 0; 531 | }; 532 | FDD73CF0219D053F00CF24B1 /* Resources */ = { 533 | isa = PBXResourcesBuildPhase; 534 | buildActionMask = 2147483647; 535 | files = ( 536 | FDD73D01219D054000CF24B1 /* LaunchScreen.storyboard in Resources */, 537 | FDD73CFE219D054000CF24B1 /* Assets.xcassets in Resources */, 538 | FDD73CFC219D053F00CF24B1 /* Main.storyboard in Resources */, 539 | ); 540 | runOnlyForDeploymentPostprocessing = 0; 541 | }; 542 | FDD73D07219D054000CF24B1 /* Resources */ = { 543 | isa = PBXResourcesBuildPhase; 544 | buildActionMask = 2147483647; 545 | files = ( 546 | ); 547 | runOnlyForDeploymentPostprocessing = 0; 548 | }; 549 | FDD73D12219D054000CF24B1 /* Resources */ = { 550 | isa = PBXResourcesBuildPhase; 551 | buildActionMask = 2147483647; 552 | files = ( 553 | ); 554 | runOnlyForDeploymentPostprocessing = 0; 555 | }; 556 | /* End PBXResourcesBuildPhase section */ 557 | 558 | /* Begin PBXShellScriptBuildPhase section */ 559 | 0865B48E833D605A20E6027D /* [CP] Check Pods Manifest.lock */ = { 560 | isa = PBXShellScriptBuildPhase; 561 | buildActionMask = 2147483647; 562 | files = ( 563 | ); 564 | inputFileListPaths = ( 565 | ); 566 | inputPaths = ( 567 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 568 | "${PODS_ROOT}/Manifest.lock", 569 | ); 570 | name = "[CP] Check Pods Manifest.lock"; 571 | outputFileListPaths = ( 572 | ); 573 | outputPaths = ( 574 | "$(DERIVED_FILE_DIR)/Pods-SwiftyFitsize_SwiftTests-checkManifestLockResult.txt", 575 | ); 576 | runOnlyForDeploymentPostprocessing = 0; 577 | shellPath = /bin/sh; 578 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 579 | showEnvVarsInLog = 0; 580 | }; 581 | /* End PBXShellScriptBuildPhase section */ 582 | 583 | /* Begin PBXSourcesBuildPhase section */ 584 | 607FACCC1AFB9204008FA782 /* Sources */ = { 585 | isa = PBXSourcesBuildPhase; 586 | buildActionMask = 2147483647; 587 | files = ( 588 | FDD73D4B219D077C00CF24B1 /* AppDelegate.swift in Sources */, 589 | FDD73D45219D077C00CF24B1 /* ViewController.swift in Sources */, 590 | FD58D9A825792722003270C8 /* LandscapeViewController.swift in Sources */, 591 | FDD73D47219D077C00CF24B1 /* FitsizeView.swift in Sources */, 592 | FD58D9FA257B4EB0003270C8 /* PortraitViewController.swift in Sources */, 593 | ); 594 | runOnlyForDeploymentPostprocessing = 0; 595 | }; 596 | 607FACE11AFB9204008FA782 /* Sources */ = { 597 | isa = PBXSourcesBuildPhase; 598 | buildActionMask = 2147483647; 599 | files = ( 600 | 607FACEC1AFB9204008FA782 /* Tests.swift in Sources */, 601 | ); 602 | runOnlyForDeploymentPostprocessing = 0; 603 | }; 604 | FDC4F7AF26D6901F002D67AE /* Sources */ = { 605 | isa = PBXSourcesBuildPhase; 606 | buildActionMask = 2147483647; 607 | files = ( 608 | FDC4F7BA26D6901F002D67AE /* ViewController.swift in Sources */, 609 | FDC4F7B626D6901F002D67AE /* AppDelegate.swift in Sources */, 610 | FDC4F7B826D6901F002D67AE /* SceneDelegate.swift in Sources */, 611 | ); 612 | runOnlyForDeploymentPostprocessing = 0; 613 | }; 614 | FDD73CEE219D053F00CF24B1 /* Sources */ = { 615 | isa = PBXSourcesBuildPhase; 616 | buildActionMask = 2147483647; 617 | files = ( 618 | FDD73CF9219D053F00CF24B1 /* ViewController.m in Sources */, 619 | FDD73D04219D054000CF24B1 /* main.m in Sources */, 620 | FDD73CF6219D053F00CF24B1 /* AppDelegate.m in Sources */, 621 | ); 622 | runOnlyForDeploymentPostprocessing = 0; 623 | }; 624 | FDD73D05219D054000CF24B1 /* Sources */ = { 625 | isa = PBXSourcesBuildPhase; 626 | buildActionMask = 2147483647; 627 | files = ( 628 | FDD73D0E219D054000CF24B1 /* SwiftyFitsize_OCTests.m in Sources */, 629 | ); 630 | runOnlyForDeploymentPostprocessing = 0; 631 | }; 632 | FDD73D10219D054000CF24B1 /* Sources */ = { 633 | isa = PBXSourcesBuildPhase; 634 | buildActionMask = 2147483647; 635 | files = ( 636 | FDD73D19219D054000CF24B1 /* SwiftyFitsize_OCUITests.m in Sources */, 637 | ); 638 | runOnlyForDeploymentPostprocessing = 0; 639 | }; 640 | /* End PBXSourcesBuildPhase section */ 641 | 642 | /* Begin PBXTargetDependency section */ 643 | 607FACE71AFB9204008FA782 /* PBXTargetDependency */ = { 644 | isa = PBXTargetDependency; 645 | target = 607FACCF1AFB9204008FA782 /* SwiftyFitsize_Swift */; 646 | targetProxy = 607FACE61AFB9204008FA782 /* PBXContainerItemProxy */; 647 | }; 648 | FDD73D0B219D054000CF24B1 /* PBXTargetDependency */ = { 649 | isa = PBXTargetDependency; 650 | target = FDD73CF1219D053F00CF24B1 /* SwiftyFitsize_OC */; 651 | targetProxy = FDD73D0A219D054000CF24B1 /* PBXContainerItemProxy */; 652 | }; 653 | FDD73D16219D054000CF24B1 /* PBXTargetDependency */ = { 654 | isa = PBXTargetDependency; 655 | target = FDD73CF1219D053F00CF24B1 /* SwiftyFitsize_OC */; 656 | targetProxy = FDD73D15219D054000CF24B1 /* PBXContainerItemProxy */; 657 | }; 658 | /* End PBXTargetDependency section */ 659 | 660 | /* Begin PBXVariantGroup section */ 661 | FDC4F7BB26D6901F002D67AE /* Main.storyboard */ = { 662 | isa = PBXVariantGroup; 663 | children = ( 664 | FDC4F7BC26D6901F002D67AE /* Base */, 665 | ); 666 | name = Main.storyboard; 667 | sourceTree = ""; 668 | }; 669 | FDC4F7C026D69021002D67AE /* LaunchScreen.storyboard */ = { 670 | isa = PBXVariantGroup; 671 | children = ( 672 | FDC4F7C126D69021002D67AE /* Base */, 673 | ); 674 | name = LaunchScreen.storyboard; 675 | sourceTree = ""; 676 | }; 677 | FDD73CFA219D053F00CF24B1 /* Main.storyboard */ = { 678 | isa = PBXVariantGroup; 679 | children = ( 680 | FDD73CFB219D053F00CF24B1 /* Base */, 681 | ); 682 | name = Main.storyboard; 683 | sourceTree = ""; 684 | }; 685 | FDD73CFF219D054000CF24B1 /* LaunchScreen.storyboard */ = { 686 | isa = PBXVariantGroup; 687 | children = ( 688 | FDD73D00219D054000CF24B1 /* Base */, 689 | ); 690 | name = LaunchScreen.storyboard; 691 | sourceTree = ""; 692 | }; 693 | FDD73D3E219D077C00CF24B1 /* LaunchScreen.xib */ = { 694 | isa = PBXVariantGroup; 695 | children = ( 696 | FDD73D3F219D077C00CF24B1 /* Base */, 697 | ); 698 | name = LaunchScreen.xib; 699 | sourceTree = ""; 700 | }; 701 | FDD73D40219D077C00CF24B1 /* Main.storyboard */ = { 702 | isa = PBXVariantGroup; 703 | children = ( 704 | FDD73D41219D077C00CF24B1 /* Base */, 705 | ); 706 | name = Main.storyboard; 707 | sourceTree = ""; 708 | }; 709 | /* End PBXVariantGroup section */ 710 | 711 | /* Begin XCBuildConfiguration section */ 712 | 607FACED1AFB9204008FA782 /* Debug */ = { 713 | isa = XCBuildConfiguration; 714 | buildSettings = { 715 | ALWAYS_SEARCH_USER_PATHS = NO; 716 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 717 | CLANG_CXX_LIBRARY = "libc++"; 718 | CLANG_ENABLE_MODULES = YES; 719 | CLANG_ENABLE_OBJC_ARC = YES; 720 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 721 | CLANG_WARN_BOOL_CONVERSION = YES; 722 | CLANG_WARN_COMMA = YES; 723 | CLANG_WARN_CONSTANT_CONVERSION = YES; 724 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 725 | CLANG_WARN_EMPTY_BODY = YES; 726 | CLANG_WARN_ENUM_CONVERSION = YES; 727 | CLANG_WARN_INFINITE_RECURSION = YES; 728 | CLANG_WARN_INT_CONVERSION = YES; 729 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 730 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 731 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 732 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 733 | CLANG_WARN_STRICT_PROTOTYPES = YES; 734 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 735 | CLANG_WARN_UNREACHABLE_CODE = YES; 736 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 737 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 738 | COPY_PHASE_STRIP = NO; 739 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 740 | ENABLE_STRICT_OBJC_MSGSEND = YES; 741 | ENABLE_TESTABILITY = YES; 742 | GCC_C_LANGUAGE_STANDARD = gnu99; 743 | GCC_DYNAMIC_NO_PIC = NO; 744 | GCC_NO_COMMON_BLOCKS = YES; 745 | GCC_OPTIMIZATION_LEVEL = 0; 746 | GCC_PREPROCESSOR_DEFINITIONS = ( 747 | "DEBUG=1", 748 | "$(inherited)", 749 | ); 750 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 751 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 752 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 753 | GCC_WARN_UNDECLARED_SELECTOR = YES; 754 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 755 | GCC_WARN_UNUSED_FUNCTION = YES; 756 | GCC_WARN_UNUSED_VARIABLE = YES; 757 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 758 | MTL_ENABLE_DEBUG_INFO = YES; 759 | ONLY_ACTIVE_ARCH = YES; 760 | SDKROOT = iphoneos; 761 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 762 | }; 763 | name = Debug; 764 | }; 765 | 607FACEE1AFB9204008FA782 /* Release */ = { 766 | isa = XCBuildConfiguration; 767 | buildSettings = { 768 | ALWAYS_SEARCH_USER_PATHS = NO; 769 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 770 | CLANG_CXX_LIBRARY = "libc++"; 771 | CLANG_ENABLE_MODULES = YES; 772 | CLANG_ENABLE_OBJC_ARC = YES; 773 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 774 | CLANG_WARN_BOOL_CONVERSION = YES; 775 | CLANG_WARN_COMMA = YES; 776 | CLANG_WARN_CONSTANT_CONVERSION = YES; 777 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 778 | CLANG_WARN_EMPTY_BODY = YES; 779 | CLANG_WARN_ENUM_CONVERSION = YES; 780 | CLANG_WARN_INFINITE_RECURSION = YES; 781 | CLANG_WARN_INT_CONVERSION = YES; 782 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 783 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 784 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 785 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 786 | CLANG_WARN_STRICT_PROTOTYPES = YES; 787 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 788 | CLANG_WARN_UNREACHABLE_CODE = YES; 789 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 790 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 791 | COPY_PHASE_STRIP = NO; 792 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 793 | ENABLE_NS_ASSERTIONS = NO; 794 | ENABLE_STRICT_OBJC_MSGSEND = YES; 795 | GCC_C_LANGUAGE_STANDARD = gnu99; 796 | GCC_NO_COMMON_BLOCKS = YES; 797 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 798 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 799 | GCC_WARN_UNDECLARED_SELECTOR = YES; 800 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 801 | GCC_WARN_UNUSED_FUNCTION = YES; 802 | GCC_WARN_UNUSED_VARIABLE = YES; 803 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 804 | MTL_ENABLE_DEBUG_INFO = NO; 805 | SDKROOT = iphoneos; 806 | SWIFT_COMPILATION_MODE = wholemodule; 807 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 808 | VALIDATE_PRODUCT = YES; 809 | }; 810 | name = Release; 811 | }; 812 | 607FACF01AFB9204008FA782 /* Debug */ = { 813 | isa = XCBuildConfiguration; 814 | buildSettings = { 815 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 816 | INFOPLIST_FILE = Swift/SwiftyFitsize/Info.plist; 817 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 818 | LD_RUNPATH_SEARCH_PATHS = ( 819 | "$(inherited)", 820 | "@executable_path/Frameworks", 821 | ); 822 | MODULE_NAME = ExampleApp; 823 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; 824 | PRODUCT_NAME = "$(TARGET_NAME)"; 825 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 826 | SWIFT_VERSION = 5.0; 827 | TARGETED_DEVICE_FAMILY = "1,2"; 828 | }; 829 | name = Debug; 830 | }; 831 | 607FACF11AFB9204008FA782 /* Release */ = { 832 | isa = XCBuildConfiguration; 833 | buildSettings = { 834 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 835 | INFOPLIST_FILE = Swift/SwiftyFitsize/Info.plist; 836 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 837 | LD_RUNPATH_SEARCH_PATHS = ( 838 | "$(inherited)", 839 | "@executable_path/Frameworks", 840 | ); 841 | MODULE_NAME = ExampleApp; 842 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; 843 | PRODUCT_NAME = "$(TARGET_NAME)"; 844 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 845 | SWIFT_VERSION = 5.0; 846 | TARGETED_DEVICE_FAMILY = "1,2"; 847 | }; 848 | name = Release; 849 | }; 850 | 607FACF31AFB9204008FA782 /* Debug */ = { 851 | isa = XCBuildConfiguration; 852 | buildSettings = { 853 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 854 | FRAMEWORK_SEARCH_PATHS = ( 855 | "$(SDKROOT)/Developer/Library/Frameworks", 856 | "$(inherited)", 857 | ); 858 | GCC_PREPROCESSOR_DEFINITIONS = ( 859 | "DEBUG=1", 860 | "$(inherited)", 861 | ); 862 | INFOPLIST_FILE = Swift/Tests/Info.plist; 863 | LD_RUNPATH_SEARCH_PATHS = ( 864 | "$(inherited)", 865 | "@executable_path/Frameworks", 866 | "@loader_path/Frameworks", 867 | ); 868 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; 869 | PRODUCT_NAME = "$(TARGET_NAME)"; 870 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 871 | SWIFT_VERSION = 4.0; 872 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftyFitsize_Example.app/SwiftyFitsize_Example"; 873 | }; 874 | name = Debug; 875 | }; 876 | 607FACF41AFB9204008FA782 /* Release */ = { 877 | isa = XCBuildConfiguration; 878 | buildSettings = { 879 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 880 | FRAMEWORK_SEARCH_PATHS = ( 881 | "$(SDKROOT)/Developer/Library/Frameworks", 882 | "$(inherited)", 883 | ); 884 | INFOPLIST_FILE = Swift/Tests/Info.plist; 885 | LD_RUNPATH_SEARCH_PATHS = ( 886 | "$(inherited)", 887 | "@executable_path/Frameworks", 888 | "@loader_path/Frameworks", 889 | ); 890 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; 891 | PRODUCT_NAME = "$(TARGET_NAME)"; 892 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 893 | SWIFT_VERSION = 4.0; 894 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftyFitsize_Example.app/SwiftyFitsize_Example"; 895 | }; 896 | name = Release; 897 | }; 898 | FDC4F7C426D69021002D67AE /* Debug */ = { 899 | isa = XCBuildConfiguration; 900 | buildSettings = { 901 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 902 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 903 | CLANG_ANALYZER_NONNULL = YES; 904 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 905 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 906 | CLANG_ENABLE_OBJC_WEAK = YES; 907 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 908 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 909 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 910 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 911 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 912 | CODE_SIGN_STYLE = Automatic; 913 | DEBUG_INFORMATION_FORMAT = dwarf; 914 | DEVELOPMENT_TEAM = 2RA5LSHPUJ; 915 | GCC_C_LANGUAGE_STANDARD = gnu11; 916 | INFOPLIST_FILE = "$(SRCROOT)/Scene/Info.plist"; 917 | IPHONEOS_DEPLOYMENT_TARGET = 14.5; 918 | LD_RUNPATH_SEARCH_PATHS = ( 919 | "$(inherited)", 920 | "@executable_path/Frameworks", 921 | ); 922 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 923 | MTL_FAST_MATH = YES; 924 | PRODUCT_BUNDLE_IDENTIFIER = "com.lxf.SwiftyFitsize-Scene"; 925 | PRODUCT_NAME = "$(TARGET_NAME)"; 926 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 927 | SWIFT_VERSION = 5.0; 928 | TARGETED_DEVICE_FAMILY = 1; 929 | }; 930 | name = Debug; 931 | }; 932 | FDC4F7C526D69021002D67AE /* Release */ = { 933 | isa = XCBuildConfiguration; 934 | buildSettings = { 935 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 936 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 937 | CLANG_ANALYZER_NONNULL = YES; 938 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 939 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 940 | CLANG_ENABLE_OBJC_WEAK = YES; 941 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 942 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 943 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 944 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 945 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 946 | CODE_SIGN_STYLE = Automatic; 947 | DEVELOPMENT_TEAM = 2RA5LSHPUJ; 948 | GCC_C_LANGUAGE_STANDARD = gnu11; 949 | INFOPLIST_FILE = "$(SRCROOT)/Scene/Info.plist"; 950 | IPHONEOS_DEPLOYMENT_TARGET = 14.5; 951 | LD_RUNPATH_SEARCH_PATHS = ( 952 | "$(inherited)", 953 | "@executable_path/Frameworks", 954 | ); 955 | MTL_FAST_MATH = YES; 956 | PRODUCT_BUNDLE_IDENTIFIER = "com.lxf.SwiftyFitsize-Scene"; 957 | PRODUCT_NAME = "$(TARGET_NAME)"; 958 | SWIFT_VERSION = 5.0; 959 | TARGETED_DEVICE_FAMILY = 1; 960 | }; 961 | name = Release; 962 | }; 963 | FDD73D1B219D054000CF24B1 /* Debug */ = { 964 | isa = XCBuildConfiguration; 965 | buildSettings = { 966 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 967 | CLANG_ANALYZER_NONNULL = YES; 968 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 969 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 970 | CLANG_ENABLE_MODULES = YES; 971 | CLANG_ENABLE_OBJC_WEAK = YES; 972 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 973 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 974 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 975 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 976 | CODE_SIGN_IDENTITY = "iPhone Developer"; 977 | CODE_SIGN_STYLE = Automatic; 978 | DEBUG_INFORMATION_FORMAT = dwarf; 979 | GCC_C_LANGUAGE_STANDARD = gnu11; 980 | GCC_PREPROCESSOR_DEFINITIONS = ( 981 | "DEBUG=1", 982 | "$(inherited)", 983 | "LXF_SWIFT_PACKAGE=1", 984 | ); 985 | INFOPLIST_FILE = OC/SwiftyFitsize/Info.plist; 986 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 987 | LD_RUNPATH_SEARCH_PATHS = ( 988 | "$(inherited)", 989 | "@executable_path/Frameworks", 990 | ); 991 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 992 | MTL_FAST_MATH = YES; 993 | PRODUCT_BUNDLE_IDENTIFIER = "com.lxf.SwiftyFitsize-OC"; 994 | PRODUCT_NAME = "$(TARGET_NAME)"; 995 | SWIFT_OBJC_BRIDGING_HEADER = ""; 996 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 997 | SWIFT_VERSION = 4.2; 998 | TARGETED_DEVICE_FAMILY = "1,2"; 999 | }; 1000 | name = Debug; 1001 | }; 1002 | FDD73D1C219D054000CF24B1 /* Release */ = { 1003 | isa = XCBuildConfiguration; 1004 | buildSettings = { 1005 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 1006 | CLANG_ANALYZER_NONNULL = YES; 1007 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 1008 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 1009 | CLANG_ENABLE_MODULES = YES; 1010 | CLANG_ENABLE_OBJC_WEAK = YES; 1011 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 1012 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 1013 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 1014 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 1015 | CODE_SIGN_IDENTITY = "iPhone Developer"; 1016 | CODE_SIGN_STYLE = Automatic; 1017 | GCC_C_LANGUAGE_STANDARD = gnu11; 1018 | GCC_PREPROCESSOR_DEFINITIONS = "LXF_SWIFT_PACKAGE=1"; 1019 | INFOPLIST_FILE = OC/SwiftyFitsize/Info.plist; 1020 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 1021 | LD_RUNPATH_SEARCH_PATHS = ( 1022 | "$(inherited)", 1023 | "@executable_path/Frameworks", 1024 | ); 1025 | MTL_FAST_MATH = YES; 1026 | PRODUCT_BUNDLE_IDENTIFIER = "com.lxf.SwiftyFitsize-OC"; 1027 | PRODUCT_NAME = "$(TARGET_NAME)"; 1028 | SWIFT_OBJC_BRIDGING_HEADER = ""; 1029 | SWIFT_VERSION = 4.2; 1030 | TARGETED_DEVICE_FAMILY = "1,2"; 1031 | }; 1032 | name = Release; 1033 | }; 1034 | FDD73D1D219D054000CF24B1 /* Debug */ = { 1035 | isa = XCBuildConfiguration; 1036 | buildSettings = { 1037 | BUNDLE_LOADER = "$(TEST_HOST)"; 1038 | CLANG_ANALYZER_NONNULL = YES; 1039 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 1040 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 1041 | CLANG_ENABLE_OBJC_WEAK = YES; 1042 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 1043 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 1044 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 1045 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 1046 | CODE_SIGN_IDENTITY = "iPhone Developer"; 1047 | CODE_SIGN_STYLE = Automatic; 1048 | DEBUG_INFORMATION_FORMAT = dwarf; 1049 | GCC_C_LANGUAGE_STANDARD = gnu11; 1050 | INFOPLIST_FILE = OC/Tests/Info.plist; 1051 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 1052 | LD_RUNPATH_SEARCH_PATHS = ( 1053 | "$(inherited)", 1054 | "@executable_path/Frameworks", 1055 | "@loader_path/Frameworks", 1056 | ); 1057 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 1058 | MTL_FAST_MATH = YES; 1059 | PRODUCT_BUNDLE_IDENTIFIER = "com.lxf.SwiftyFitsize-OCTests"; 1060 | PRODUCT_NAME = "$(TARGET_NAME)"; 1061 | TARGETED_DEVICE_FAMILY = "1,2"; 1062 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftyFitsize-OC.app/SwiftyFitsize-OC"; 1063 | }; 1064 | name = Debug; 1065 | }; 1066 | FDD73D1E219D054000CF24B1 /* Release */ = { 1067 | isa = XCBuildConfiguration; 1068 | buildSettings = { 1069 | BUNDLE_LOADER = "$(TEST_HOST)"; 1070 | CLANG_ANALYZER_NONNULL = YES; 1071 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 1072 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 1073 | CLANG_ENABLE_OBJC_WEAK = YES; 1074 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 1075 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 1076 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 1077 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 1078 | CODE_SIGN_IDENTITY = "iPhone Developer"; 1079 | CODE_SIGN_STYLE = Automatic; 1080 | GCC_C_LANGUAGE_STANDARD = gnu11; 1081 | INFOPLIST_FILE = OC/Tests/Info.plist; 1082 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 1083 | LD_RUNPATH_SEARCH_PATHS = ( 1084 | "$(inherited)", 1085 | "@executable_path/Frameworks", 1086 | "@loader_path/Frameworks", 1087 | ); 1088 | MTL_FAST_MATH = YES; 1089 | PRODUCT_BUNDLE_IDENTIFIER = "com.lxf.SwiftyFitsize-OCTests"; 1090 | PRODUCT_NAME = "$(TARGET_NAME)"; 1091 | TARGETED_DEVICE_FAMILY = "1,2"; 1092 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftyFitsize-OC.app/SwiftyFitsize-OC"; 1093 | }; 1094 | name = Release; 1095 | }; 1096 | FDD73D1F219D054000CF24B1 /* Debug */ = { 1097 | isa = XCBuildConfiguration; 1098 | buildSettings = { 1099 | CLANG_ANALYZER_NONNULL = YES; 1100 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 1101 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 1102 | CLANG_ENABLE_OBJC_WEAK = YES; 1103 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 1104 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 1105 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 1106 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 1107 | CODE_SIGN_IDENTITY = "iPhone Developer"; 1108 | CODE_SIGN_STYLE = Automatic; 1109 | DEBUG_INFORMATION_FORMAT = dwarf; 1110 | GCC_C_LANGUAGE_STANDARD = gnu11; 1111 | INFOPLIST_FILE = OC/UITests/Info.plist; 1112 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 1113 | LD_RUNPATH_SEARCH_PATHS = ( 1114 | "$(inherited)", 1115 | "@executable_path/Frameworks", 1116 | "@loader_path/Frameworks", 1117 | ); 1118 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 1119 | MTL_FAST_MATH = YES; 1120 | PRODUCT_BUNDLE_IDENTIFIER = "com.lxf.SwiftyFitsize-OCUITests"; 1121 | PRODUCT_NAME = "$(TARGET_NAME)"; 1122 | TARGETED_DEVICE_FAMILY = "1,2"; 1123 | TEST_TARGET_NAME = "SwiftyFitsize-OC"; 1124 | }; 1125 | name = Debug; 1126 | }; 1127 | FDD73D20219D054000CF24B1 /* Release */ = { 1128 | isa = XCBuildConfiguration; 1129 | buildSettings = { 1130 | CLANG_ANALYZER_NONNULL = YES; 1131 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 1132 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 1133 | CLANG_ENABLE_OBJC_WEAK = YES; 1134 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 1135 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 1136 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 1137 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 1138 | CODE_SIGN_IDENTITY = "iPhone Developer"; 1139 | CODE_SIGN_STYLE = Automatic; 1140 | GCC_C_LANGUAGE_STANDARD = gnu11; 1141 | INFOPLIST_FILE = OC/UITests/Info.plist; 1142 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 1143 | LD_RUNPATH_SEARCH_PATHS = ( 1144 | "$(inherited)", 1145 | "@executable_path/Frameworks", 1146 | "@loader_path/Frameworks", 1147 | ); 1148 | MTL_FAST_MATH = YES; 1149 | PRODUCT_BUNDLE_IDENTIFIER = "com.lxf.SwiftyFitsize-OCUITests"; 1150 | PRODUCT_NAME = "$(TARGET_NAME)"; 1151 | TARGETED_DEVICE_FAMILY = "1,2"; 1152 | TEST_TARGET_NAME = "SwiftyFitsize-OC"; 1153 | }; 1154 | name = Release; 1155 | }; 1156 | /* End XCBuildConfiguration section */ 1157 | 1158 | /* Begin XCConfigurationList section */ 1159 | 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "SwiftyFitsizePackage" */ = { 1160 | isa = XCConfigurationList; 1161 | buildConfigurations = ( 1162 | 607FACED1AFB9204008FA782 /* Debug */, 1163 | 607FACEE1AFB9204008FA782 /* Release */, 1164 | ); 1165 | defaultConfigurationIsVisible = 0; 1166 | defaultConfigurationName = Release; 1167 | }; 1168 | 607FACEF1AFB9204008FA782 /* Build configuration list for PBXNativeTarget "SwiftyFitsize_Swift" */ = { 1169 | isa = XCConfigurationList; 1170 | buildConfigurations = ( 1171 | 607FACF01AFB9204008FA782 /* Debug */, 1172 | 607FACF11AFB9204008FA782 /* Release */, 1173 | ); 1174 | defaultConfigurationIsVisible = 0; 1175 | defaultConfigurationName = Release; 1176 | }; 1177 | 607FACF21AFB9204008FA782 /* Build configuration list for PBXNativeTarget "SwiftyFitsize_SwiftTests" */ = { 1178 | isa = XCConfigurationList; 1179 | buildConfigurations = ( 1180 | 607FACF31AFB9204008FA782 /* Debug */, 1181 | 607FACF41AFB9204008FA782 /* Release */, 1182 | ); 1183 | defaultConfigurationIsVisible = 0; 1184 | defaultConfigurationName = Release; 1185 | }; 1186 | FDC4F7C626D69021002D67AE /* Build configuration list for PBXNativeTarget "SwiftyFitsize_Scene" */ = { 1187 | isa = XCConfigurationList; 1188 | buildConfigurations = ( 1189 | FDC4F7C426D69021002D67AE /* Debug */, 1190 | FDC4F7C526D69021002D67AE /* Release */, 1191 | ); 1192 | defaultConfigurationIsVisible = 0; 1193 | defaultConfigurationName = Release; 1194 | }; 1195 | FDD73D21219D054000CF24B1 /* Build configuration list for PBXNativeTarget "SwiftyFitsize_OC" */ = { 1196 | isa = XCConfigurationList; 1197 | buildConfigurations = ( 1198 | FDD73D1B219D054000CF24B1 /* Debug */, 1199 | FDD73D1C219D054000CF24B1 /* Release */, 1200 | ); 1201 | defaultConfigurationIsVisible = 0; 1202 | defaultConfigurationName = Release; 1203 | }; 1204 | FDD73D22219D054000CF24B1 /* Build configuration list for PBXNativeTarget "SwiftyFitsize_OCTests" */ = { 1205 | isa = XCConfigurationList; 1206 | buildConfigurations = ( 1207 | FDD73D1D219D054000CF24B1 /* Debug */, 1208 | FDD73D1E219D054000CF24B1 /* Release */, 1209 | ); 1210 | defaultConfigurationIsVisible = 0; 1211 | defaultConfigurationName = Release; 1212 | }; 1213 | FDD73D23219D054000CF24B1 /* Build configuration list for PBXNativeTarget "SwiftyFitsize_OCUITests" */ = { 1214 | isa = XCConfigurationList; 1215 | buildConfigurations = ( 1216 | FDD73D1F219D054000CF24B1 /* Debug */, 1217 | FDD73D20219D054000CF24B1 /* Release */, 1218 | ); 1219 | defaultConfigurationIsVisible = 0; 1220 | defaultConfigurationName = Release; 1221 | }; 1222 | /* End XCConfigurationList section */ 1223 | 1224 | /* Begin XCRemoteSwiftPackageReference section */ 1225 | FD46E45C2864C3D000C80FDF /* XCRemoteSwiftPackageReference "SnapKit" */ = { 1226 | isa = XCRemoteSwiftPackageReference; 1227 | repositoryURL = "https://github.com/SnapKit/SnapKit.git"; 1228 | requirement = { 1229 | kind = upToNextMajorVersion; 1230 | minimumVersion = 5.0.0; 1231 | }; 1232 | }; 1233 | /* End XCRemoteSwiftPackageReference section */ 1234 | 1235 | /* Begin XCSwiftPackageProductDependency section */ 1236 | FD46E4572864BCD400C80FDF /* SwiftyFitsize */ = { 1237 | isa = XCSwiftPackageProductDependency; 1238 | productName = SwiftyFitsize; 1239 | }; 1240 | FD46E45D2864C3D000C80FDF /* SnapKit */ = { 1241 | isa = XCSwiftPackageProductDependency; 1242 | package = FD46E45C2864C3D000C80FDF /* XCRemoteSwiftPackageReference "SnapKit" */; 1243 | productName = SnapKit; 1244 | }; 1245 | FD7BFAAB2866F09F002B2F01 /* SwiftyFitsize */ = { 1246 | isa = XCSwiftPackageProductDependency; 1247 | productName = SwiftyFitsize; 1248 | }; 1249 | FD7BFAAD2866F0AA002B2F01 /* SwiftyFitsize */ = { 1250 | isa = XCSwiftPackageProductDependency; 1251 | productName = SwiftyFitsize; 1252 | }; 1253 | FD7BFAAF2866F76D002B2F01 /* SnapKit */ = { 1254 | isa = XCSwiftPackageProductDependency; 1255 | package = FD46E45C2864C3D000C80FDF /* XCRemoteSwiftPackageReference "SnapKit" */; 1256 | productName = SnapKit; 1257 | }; 1258 | /* End XCSwiftPackageProductDependency section */ 1259 | }; 1260 | rootObject = 607FACC81AFB9204008FA782 /* Project object */; 1261 | } 1262 | -------------------------------------------------------------------------------- /Example/SwiftyFitsizePackage.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/SwiftyFitsizePackage.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Example/SwiftyFitsizePackage.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved: -------------------------------------------------------------------------------- 1 | { 2 | "pins" : [ 3 | { 4 | "identity" : "snapkit", 5 | "kind" : "remoteSourceControl", 6 | "location" : "https://github.com/SnapKit/SnapKit.git", 7 | "state" : { 8 | "revision" : "f222cbdf325885926566172f6f5f06af95473158", 9 | "version" : "5.6.0" 10 | } 11 | } 12 | ], 13 | "version" : 2 14 | } 15 | -------------------------------------------------------------------------------- /Example/SwiftyFitsizePackage.xcodeproj/xcshareddata/xcschemes/SwiftyFitsize_OC.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 63 | 65 | 71 | 72 | 73 | 74 | 80 | 82 | 88 | 89 | 90 | 91 | 93 | 94 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 LinXunFeng <598600855@qq.com> 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version: 5.6 2 | // The swift-tools-version declares the minimum version of Swift required to build this package. 3 | 4 | import PackageDescription 5 | 6 | let package = Package( 7 | name: "SwiftyFitsize", 8 | platforms: [ 9 | .iOS(.v9), 10 | ], 11 | products: [ 12 | // Products define the executables and libraries a package produces, and make them visible to other packages. 13 | .library( 14 | name: "SwiftyFitsize", 15 | targets: ["SwiftyFitsize", "SwiftyFitsizeOCSupport"] 16 | ), 17 | ], 18 | dependencies: [ 19 | // Dependencies declare other packages that this package depends on. 20 | // .package(url: /* package url */, from: "1.0.0"), 21 | ], 22 | targets: [ 23 | // Targets are the basic building blocks of a package. A target can define a module or a test suite. 24 | // Targets can depend on other targets in this package, and on products in packages this package depends on. 25 | .target( 26 | name: "SwiftyFitsize" 27 | ), 28 | .target( 29 | name: "SwiftyFitsizeOCSupport", 30 | dependencies: ["SwiftyFitsize"] 31 | ), 32 | ], 33 | swiftLanguageVersions: [.v5] 34 | ) 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SwiftyFitsize 2 | 3 | ![Author](https://img.shields.io/badge/author-LinXunFeng-blue.svg?style=flat-square) 4 | [![CI Status](https://img.shields.io/travis/LinXunFeng/SwiftyFitsize.svg?style=flat)](https://travis-ci.org/LinXunFeng/SwiftyFitsize) 5 | [![Version](https://img.shields.io/cocoapods/v/SwiftyFitsize.svg?style=flat)](https://cocoapods.org/pods/SwiftyFitsize) 6 | [![License](https://img.shields.io/cocoapods/l/SwiftyFitsize.svg?style=flat)](https://cocoapods.org/pods/SwiftyFitsize) 7 | [![Platform](https://img.shields.io/cocoapods/p/SwiftyFitsize.svg?style=flat)](https://cocoapods.org/pods/SwiftyFitsize) 8 | ![visitors](https://visitor-badge.glitch.me/badge?page_id=LinXunFeng.SwiftyFitsize) 9 | 10 | ## Example 11 | 12 | 克隆或下载仓库到本地后,请先运行 `pod install` , 再打开 `SwiftyFitsize.xcworkspace` 13 | 14 | ## Requirements 15 | 16 | - iOS 9.0+ 17 | - Xcode 10.2+ 18 | - Swift 5+ 19 | 20 | ## Installation 21 | 22 | - Cocoapods 23 | 24 | ```ruby 25 | use_frameworks! 26 | pod 'SwiftyFitsize' 27 | ``` 28 | 29 | 30 | 31 | - Swift Package Manager 32 | 33 | ``` 34 | 1. File > Add Packages 35 | 2. Search https://github.com/LinXunFeng/SwiftyFitsize.git 36 | 3. Select "Up to Next Major" with "1.4.1" 37 | ``` 38 | 39 | 40 | 41 | ## Exhibition 42 | 43 | ![iPhone](https://github.com/LinXunFeng/SwiftyFitsize/raw/master/Screenshots/exhibition.png) 44 | 45 | 46 | 47 | ![iPad](./Screenshots/ipad.png) 48 | 49 | 50 | 51 | ## Usage 52 | 53 | ### 一、运算符 54 | 55 | > 无论是 `~` 还是 `≈` 对 `iPhone` 的适配效果是一样的。而对 `iPad` 而言,`iPad` 的宽度太大,使用 `≈` 还是会按宽度比例进行运算,就会显示特别臃肿,这时使用 `~` 在显示上就会比较合适。 56 | > 57 | > - `~` 在 `≈` 的基础上针对 `iPad` 的适配大小后再去乘上 `iPadFitMultiple` 。 58 | >- 一般情况下直接使用 `~` 即可。 59 | > - 其它运算符亦是如此,具体请看下方的说明表 60 | 61 | 62 | 63 | | 运算符 | 说明 | 64 | | ------ | ------------------------------------------------------------ | 65 | | `~` | 对比宽度,当设备为 `iPad` 时,适配后的 `value` 会再乘上 `iPadFitMultiple` | 66 | | `≈` | 对比宽度,强制适配,不论是 `iPhone` 还是 `iPad` 都不会乘上 `iPadFitMultiple` | 67 | | `∣` | 对比高度,对应 `~` ,整屏高度 | 68 | | `∥` | 对比高度,对应 `≈` ,整屏高度 | 69 | | `∣=` | 对比高度,对应 `∣` ,安全区域内的高度 | 70 | | `∥=` | 对比高度,对应 `∥` ,安全区域内的高度 | 71 | | `∣-` | 对比高度,对应 `∣` ,除去刘海区域的安全区域内的高度 | 72 | | `∥-` | 对比高度,对应 `∥` ,除去刘海区域的安全区域内的高度 | 73 | 74 | 各高度适配的对比 75 | 76 | >- 红色: `∣` 和 `∥` ,以整个屏幕的高度进行适配 77 | >- 蓝色: `∣=` 和 `∥=` 以中心安全区域的高度进行适配 78 | >- 绿色: `∣-` 和 `∥-` 以包括底部的安全区域进行适配 79 | 80 | ![高度适配对比](./Screenshots/fitsize-height.jpg) 81 | 82 | 83 | 84 | 举个例子 85 | 86 | `~` : 当设备为 `iPad` 时,适配后的值会与 `iPadFitMultiple` 相乘 87 | 88 | ```swift 89 | 100~ 90 | UIFont.systemFont(ofSize: 14)~ 91 | CGPoint(x: 10, y: 10)~ 92 | CGRect(x: 10, y: 10, width: 100, height: 100)~ 93 | UIEdgeInsetsMake(10, 10, 10, 10)~ 94 | ``` 95 | 96 | 97 | 98 | `≈` : (option + x) 适配后的值不会与 `iPadFitMultiple` 相乘 99 | 100 | ```swift 101 | 100≈ 102 | UIFont.systemFont(ofSize: 14)≈ 103 | CGPoint(x: 10, y: 10)≈ 104 | CGRect(x: 10, y: 10, width: 100, height: 100)≈ 105 | UIEdgeInsetsMake(10, 10, 10, 10)≈ 106 | ``` 107 | 108 | 109 | 110 | 修改 `参照宽度` 、`参照高度`、`是否为iPhoneX系列的参照高度`与 `iPadFitMultiple` 可以调用如下方法 111 | 112 | ```swift 113 | /// 设置参照的相关参数 114 | /// 115 | /// - Parameters: 116 | /// - width: 参照的宽度 117 | /// - height: 参照的高度 118 | /// - isIPhoneXSeriesHeight: 是否为iPhoneX系列的参照高度 119 | /// - iPadFitMultiple: iPad 在适配后所得值的倍数 (0 , 1] 120 | SwiftyFitsize.reference( 121 | width: 414, 122 | height: 896, 123 | isIPhoneXSeriesHeight: true, 124 | iPadFitMultiple: 0.5 125 | ) 126 | ``` 127 | 128 | 129 | 130 | ### 二、支持 xib 和 storyboard 131 | 132 | ```swift 133 | enum SwiftyFitType: Int { 134 | /// Original Value 135 | case none = 0 136 | /// ~ 137 | case flexibleWidth = 1 138 | /// ≈ 139 | case forceWidth = 2 140 | /// ∣ 141 | case flexibleHeight = 3 142 | /// ∥ 143 | case forceHeight = 4 144 | /// ∣= 145 | case flexibleSafeAreaCenterHeight = 5 146 | /// ∥= 147 | case forceSafeAreaCenterHeight = 6 148 | /// ∣- 149 | case flexibleSafeAreaWithoutTopHeight = 7 150 | /// ∥- 151 | case forceSafeAreaWithoutTopHeight = 8 152 | } 153 | ``` 154 | 155 | - Font Fitsize 156 | 157 | 支持的UI控件有: `UILabel` `UIButton` `UITextView` `UITextField` 158 | 159 | `FontFitType` 的值请参考上方的 `enum SwiftyFitType` 160 | 161 | ![xib-font](./Screenshots/xib-font.png) 162 | 163 | 164 | 165 | - Constraint Fitsize 166 | 167 | 约束适配同上 168 | 169 | ![xib-font](./Screenshots/xib-constraint.png) 170 | 171 | 172 | 173 | `iPad` 关于 `~` 与 `≈` 在使用上的对比 174 | 175 | ![~与≈的对比](./Screenshots/flexible-force.jpg) 176 | 177 | 178 | 179 | 180 | 181 | ### 三、Objective-C 182 | 183 | > 1. 由于 `OC` 不支持运算符重载,所以只能用宏来适配。 184 | > 185 | > 2. `Xib` 和 `Storyboard` 则跟上方提及的使用方式相同。 186 | 187 | 188 | 189 | `Swift运算符` 与 `OC宏` 对应表 190 | 191 | | Swift运算符 | OC宏 | 192 | | ----------- | ------------ | 193 | | `~` | `SF_xx` | 194 | | `≈` | `SFZ_xx` | 195 | | `∣` | `SF_FH_xx` | 196 | | `∥` | `SFZ_FH_xx` | 197 | | `∣=` | `SF_SCH_xx` | 198 | | `∥=` | `SFZ_SCH_xx` | 199 | | `∣-` | `SF_SBH_xx` | 200 | | `∥-` | `SFZ_SBH_xx` | 201 | 202 | 注: `xx` 支持如下类型 `Font` 、`Int`、`Float`、`Point`、`Size`、`Rect`、`EdgeInsets` 203 | 204 | 205 | 206 | - 导入 207 | 208 | ```objc 209 | @import SwiftyFitsize; 210 | ``` 211 | 212 | > 注:如果你使用的是 `SPM` 添加的依赖,且需要使用到宏(如:`SF_Float`), 213 | > 214 | > 则需要导入 `SwiftyFitsizeOCSupport` ,而 `SwiftyFitsize` 可以不导入。 215 | 216 | ```objc 217 | @import SwiftyFitsizeOCSupport; 218 | ``` 219 | 220 | 221 | 222 | - 修改 `参照宽度` 、`参照高度`、`是否为iPhoneX系列的参照高度`与 `iPadFitMultiple` 223 | 224 | ```objc 225 | [SwiftyFitsize referenceWithWidth:414 226 | height:896 227 | isIPhoneXSeriesHeight:YES 228 | iPadFitMultiple:0.6]; 229 | ``` 230 | 231 | - `~` 232 | 233 | ```objc 234 | UIFont *font = [UIFont systemFontOfSize:14]; 235 | 236 | UIFont *font1 = font.sf; 237 | UIFont *font2 = SF_Font(font); 238 | 239 | CGFloat num = SF_Float(14); 240 | CGPoint point = SF_Point(CGPointMake(10, 10)); 241 | CGSize size = SF_Size(CGSizeMake(100, 100)); 242 | CGRect rect = SF_Rect(CGRectMake(10, 10, 100, 100)); 243 | UIEdgeInsets edge = SF_EdgeInsets(UIEdgeInsetsMake(0, 0, 100, 100)); 244 | 245 | ``` 246 | 247 | - `≈` 248 | 249 | ```objc 250 | UIFont *font1 = font.sfz; 251 | UIFont *font2 = SFZ_Font(font); 252 | 253 | CGFloat num = SFZ_Float(14); 254 | CGPoint point = SFZ_Point(CGPointMake(10, 10)); 255 | CGSize size = SFZ_Size(CGSizeMake(100, 100)); 256 | CGRect rect = SFZ_Rect(CGRectMake(10, 10, 100, 100)); 257 | UIEdgeInsets edge = SFZ_EdgeInsets(UIEdgeInsetsMake(0, 0, 100, 100)); 258 | ``` 259 | 260 | 其它运算符亦是如此使用 261 | 262 | 263 | 264 | ### 四、移除指定尺寸后适配 265 | 266 | > 场景:`tableView` 的左右间距在屏幕大小不同的情况下都为 `10`,在排除左右为 `10` 的间距后,再对`Cell` 进行等比适配 267 | > 268 | > 使用思路:宽度一共减去 `20` ,以剩下的大小来做适配 269 | 270 | #### Swift 271 | 272 | 建议使用 `PropertyWrapper` 方案,供下面的调用方式一和二使用 273 | 274 | ```swift 275 | 276 | struct Metric { 277 | static let tableViewLeftRightMargin: CGFloat = 10 // 定义 tableView 的左右间距 278 | ... 279 | static let tableViewHeight: CGFloat = Fit.$width(30) // 去掉左右边距后进行适配的值 280 | static let rowLeftViewWidth: CGFloat = Fit.$width(177.5) 281 | static let rowCenterViewWidth: CGFloat = Fit.$width(100.5) 282 | static let rowRightViewWidth: CGFloat = Fit.$width(77) 283 | ... 284 | } 285 | 286 | struct Fit { 287 | // @WrappedSwiftyFitsize(fitType: .flexibleWidth, reduceValue: Metric.tableViewLeftRightMargin) 288 | // fitType 默认值是 .flexibleWidth,所以可以不传 289 | @WrappedSwiftyFitsize(reduceValue: Metric.tableViewLeftRightMargin * 2) 290 | static var width: CGFloat = 375 291 | } 292 | ``` 293 | 294 | `375` 是初始化值,没有特殊意义,只为调用 `Fit.width` 时可以取到值,如果用不到 `Fit.width` 的值可以不进行初始化 295 | 296 | 调用方式: 297 | 298 | ```swift 299 | // 移除指定尺寸后的适配,调用方式: 300 | // 以下都是以适配 tableView 为例,移除 tableView 左右两侧固定的边距,以剩余的宽度来做适配 301 | 302 | // 方式一:先赋值再取值 303 | // 将 20 进行适配 304 | Fit.width = 20 305 | print("适配后的值 -- \(Fit.width)") 306 | 307 | // 方式二:使用 $ 将 width 当方法用,传入待适配的值 308 | // 将 30 进行适配 309 | let aVal = Fit.$width(30) 310 | print("适配后的值 aVal -- \(aVal)") 311 | 312 | // 方式三:调用 SwiftyFitsize.fit 方法 313 | let bVal = SwiftyFitsize.fit( 314 | size: 40, 315 | fitType: .flexibleWidth, 316 | reduceValue: Metric.tableViewLeftRightMargin * 2 317 | ) 318 | print("适配后的值 bVal -- \(bVal)") 319 | ``` 320 | 321 | 322 | 323 | #### Objective-C 324 | 325 | 这是还是以适配 `tableView` 为例,移除 tableView 左右两侧固定的边距,以剩余的宽度来做适配 326 | 327 | ```objc 328 | CGFloat fitWidth = [SwiftyFitsize fitWithSize:40 329 | fitType:SwiftyFitTypeFlexibleWidth 330 | reduceValue:20]; 331 | ``` 332 | 333 | 可以将其做为宏,以方便使用 334 | 335 | ```objc 336 | #define kFitWidth(value) \ 337 | [SwiftyFitsize fitWithSize:value fitType:SwiftyFitTypeFlexibleWidth reduceValue:20] 338 | ``` 339 | 340 | 使用宏来做适配 341 | 342 | ```objc 343 | CGFloat fitWidth = kFitWidth(40); 344 | NSLog(@"fitWidth -- %f", fitWidth); 345 | ``` 346 | 347 | 348 | 349 | 效果如包含红绿蓝的条视图所示: 350 | 351 | ![高度适配对比](./Screenshots/fitsize-reduce.jpg) 352 | 353 | 354 | 355 | ### 五、计算结果类型 356 | 357 | #### 定义 358 | 359 | ```swift 360 | /// 计算结果类型 361 | @objc public enum SwiftyFitCalcResultType: Int { 362 | /// 跟随全局配置 363 | case globalConfig 364 | /// 原始数据 365 | case raw 366 | /// 四舍五入 367 | case round 368 | /// 保留一位小数(根据第二位小数进行四舍五入) 369 | case oneDecimalPlace 370 | } 371 | ``` 372 | 373 | #### 影响范围 374 | 375 | - `.raw ` : 影响忽略不计 376 | - `.round` : 影响范围 `(-0.5, 0.5]` 377 | - `.oneDecimalPlace` : 影响范围 `(-0.05, 0.05]` 378 | 379 | #### 全局配置 380 | 381 | > - 不配置则默认为 `.raw` 382 | > - `.globalConfig` 取的就是这里配置的类型 383 | > - 如果在该处还是设置为 `.globalConfig`,则内部会将其重置为 `.raw` 384 | 385 | ```swift 386 | SwiftyFitsize.reference(width: 375, calcResultType: .oneDecimalPlace) // 全局配置计算结果为保留一位小数 387 | ``` 388 | 389 | #### 使用 390 | 391 | > 以下在不指定 `calcResultType` 参数的情况下,默认都是跟随全局配置 392 | 393 | 单独指定 `calcResultType` 394 | 395 | ```swift 396 | SwiftyFitsize.fit( 397 | size: 35, // 36 398 | fitType: .flexibleWidth, 399 | reduceValue: 10 * 2, 400 | calcResultType: .raw // .round .oneDecimalPlace 401 | ) 402 | ``` 403 | 404 | `PropertyWrapper` 方式 405 | 406 | ```swift 407 | // calcResultType: .raw .round .oneDecimalPlace 408 | @WrappedSwiftyFitsize(reduceValue: Metric.tableViewLeftRightMargin * 2, calcResultType: .raw) 409 | static var width: CGFloat = 375 410 | ``` 411 | 412 | #### 示例数据 413 | 414 | - 第一列为适配前的数值 415 | 416 | - 其它列为适配后根据不同的 `SwiftyFitCalcResultType` 计算得到的值 417 | 418 | | 原值 | raw | round | oneDecimalPlace | 419 | | ---- | ------------------ | ----- | --------------- | 420 | | 35 | 36.478873239436616 | 36.0 | 36.5 | 421 | | 36 | 37.52112676056338 | 38.0 | 37.5 | 422 | 423 | 424 | 425 | ## Misc 426 | 427 | 下面列出一些设备对应的分辨率,方便查找 428 | 429 | | 设备 | 逻辑分辨率(point) | 设备分辨率(pixel) | 430 | | ----------------------- | ----------------- | ----------------- | 431 | | SE | 320x568 | 640x1136 | 432 | | 6(S)/7/8 / SE(第二代) | 375x667 | 750x1334 | 433 | | 6(S)+/7+/8+ | 414x736 | 1080x1920 | 434 | | X(S) / 11Pro | 375x812 | 1125x2436 | 435 | | XR / 11 | 414x896 | 828x1792 | 436 | | XS Max / 11Pro Max | 414x896 | 1242x2688 | 437 | | 12 mini / 13 mini | 360x780 | 1080x2340 | 438 | | 12(Pro) / 13(Pro) | 390x844 | 1170x2532 | 439 | | 12 Pro Max / 13 Pro Max | 428x926 | 1284x2778 | 440 | 441 | 442 | 443 | ## License 444 | 445 | SwiftyFitsize is available under the MIT license. See the LICENSE file for more info. 446 | 447 | 448 | 449 | ## Author 450 | 451 | - LinXunFeng 452 | - email: [linxunfeng@yeah.net](mailto:linxunfeng@yeah.net) 453 | - Blogs: [全栈行动](https://fullstackaction.com/) | [LinXunFeng‘s Blog](http://linxunfeng.top/) | [掘金](https://juejin.im/user/58f8065e61ff4b006646c72d/posts) 454 | 455 | 456 | 457 | 458 | 459 | ## Other 460 | 461 | | | | 462 | | :----------------------------------------------------------: | :----------------------------------------------------------: | 463 | | | | 464 | 465 | -------------------------------------------------------------------------------- /Screenshots/exhibition.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LinXunFeng/SwiftyFitsize/ec3186506cade6980087f77ed9d8128d5835e740/Screenshots/exhibition.png -------------------------------------------------------------------------------- /Screenshots/fitsize-height.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LinXunFeng/SwiftyFitsize/ec3186506cade6980087f77ed9d8128d5835e740/Screenshots/fitsize-height.jpg -------------------------------------------------------------------------------- /Screenshots/fitsize-reduce.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LinXunFeng/SwiftyFitsize/ec3186506cade6980087f77ed9d8128d5835e740/Screenshots/fitsize-reduce.jpg -------------------------------------------------------------------------------- /Screenshots/flexible-force.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LinXunFeng/SwiftyFitsize/ec3186506cade6980087f77ed9d8128d5835e740/Screenshots/flexible-force.jpg -------------------------------------------------------------------------------- /Screenshots/ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LinXunFeng/SwiftyFitsize/ec3186506cade6980087f77ed9d8128d5835e740/Screenshots/ipad.png -------------------------------------------------------------------------------- /Screenshots/ipad1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LinXunFeng/SwiftyFitsize/ec3186506cade6980087f77ed9d8128d5835e740/Screenshots/ipad1.png -------------------------------------------------------------------------------- /Screenshots/xib-constraint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LinXunFeng/SwiftyFitsize/ec3186506cade6980087f77ed9d8128d5835e740/Screenshots/xib-constraint.png -------------------------------------------------------------------------------- /Screenshots/xib-constraint1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LinXunFeng/SwiftyFitsize/ec3186506cade6980087f77ed9d8128d5835e740/Screenshots/xib-constraint1.png -------------------------------------------------------------------------------- /Screenshots/xib-font.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LinXunFeng/SwiftyFitsize/ec3186506cade6980087f77ed9d8128d5835e740/Screenshots/xib-font.png -------------------------------------------------------------------------------- /Screenshots/xib-font1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LinXunFeng/SwiftyFitsize/ec3186506cade6980087f77ed9d8128d5835e740/Screenshots/xib-font1.png -------------------------------------------------------------------------------- /Sources/SwiftyFitsize/SwiftyFitsize.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftyFitsize.swift 3 | // SwiftyFitsize 4 | // 5 | // Created by LinXunFeng on 2018/10/17. 6 | // Copyright © 2018 siyu. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | // MARK:- SwiftyFitsize 12 | @objc public final class SwiftyFitsize: NSObject { 13 | public static let shared = SwiftyFitsize() 14 | private override init() { } 15 | 16 | @objc public class func sharedSwiftyFitsize() -> SwiftyFitsize { 17 | return SwiftyFitsize.shared 18 | } 19 | 20 | /// 默认参照宽度 21 | @objc public private(set) var referenceW: CGFloat = 375 22 | /// 默认参照高度 23 | @objc public private(set) var referenceH: CGFloat = 667 24 | /// 是否为iPhoneX系列的参照高度,默认否 25 | @objc public private(set) var isIPhoneXSeriesHeight: Bool = false 26 | /// 默认 iPad 适配缩放倍数 (0 , 1] 27 | @objc public private(set) var iPadFitMultiple: CGFloat = 0.5 28 | /// 计算结果类型(默认: 原始数据) 29 | @objc public private(set) var calcResultType: SwiftyFitCalcResultType = .raw 30 | 31 | /// 中间安全区域参照高度 32 | var referenceSafeAreaCenterHeight: CGFloat { 33 | return self.fetchReferenceSafeAreaCenterHeight() 34 | } 35 | /// 仅去除顶部后的安全区域参照高度 36 | var referenceSafeAreaWithoutTopHeight: CGFloat { 37 | return self.fetchReferenceSafeAreaWithoutTopHeight() 38 | } 39 | /// 适配倍数 40 | var fitMultiple: CGFloat { 41 | return Config.Device.isIPad ? SwiftyFitsize.shared.iPadFitMultiple : 1 42 | } 43 | 44 | /// 设置参照的相关参数 45 | /// 46 | /// - Parameters: 47 | /// - width: 参照的宽度 48 | /// - iPadFitMultiple: iPad 在适配后所得值的倍数 (0 , 1] 49 | @available(iOS, introduced: 0.3, deprecated: 1.1.0, message: "Use -[SwiftyFitsize referenceWithWidth:height:isIPhoneXSeriesHeight:iPadFitMultiple:]") 50 | @objc public static func reference( 51 | width: CGFloat, 52 | iPadFitMultiple: CGFloat 53 | ) { 54 | self.reference(width: width, height: 667, isIPhoneXSeriesHeight: false, iPadFitMultiple: iPadFitMultiple) 55 | } 56 | 57 | /// 设置参照的相关参数 58 | /// - Parameters: 59 | /// - width: 参照的宽度 60 | /// - height: 参照的高度 61 | /// - isIPhoneXSeriesHeight: 是否为iPhoneX系列的参照高度 62 | /// - iPadFitMultiple: iPad 在适配后所得值的倍数 (0 , 1] 63 | /// - calcResultType: 计算结果类型(默认:原始数据),如果传入的是.globalConfig,则会修改为.raw 64 | @objc public static func reference( 65 | width: CGFloat, 66 | height: CGFloat = 667, 67 | isIPhoneXSeriesHeight: Bool = false, 68 | iPadFitMultiple: CGFloat = 0.5, 69 | calcResultType: SwiftyFitCalcResultType = .raw 70 | ) { 71 | SwiftyFitsize.shared.referenceW = width 72 | SwiftyFitsize.shared.referenceH = height 73 | SwiftyFitsize.shared.isIPhoneXSeriesHeight = isIPhoneXSeriesHeight 74 | SwiftyFitsize.shared.iPadFitMultiple = 75 | (iPadFitMultiple > 1 || iPadFitMultiple < 0) ? 1 : iPadFitMultiple 76 | 77 | var finalCalcResultType: SwiftyFitCalcResultType = calcResultType 78 | switch calcResultType { 79 | case .globalConfig: finalCalcResultType = .raw 80 | default: break 81 | } 82 | SwiftyFitsize.shared.calcResultType = finalCalcResultType 83 | } 84 | 85 | /// 适配方法 86 | /// - Parameters: 87 | /// - size: 大小 88 | /// - fitType: 适配方式 89 | /// - reduceValue: 要额外减少的数值 90 | /// - Returns: 适配后的数值 91 | @objc public static func fit( 92 | size: CGFloat, 93 | fitType: SwiftyFitType, 94 | reduceValue: CGFloat = 0 95 | ) -> CGFloat { 96 | return Self.fit( 97 | size: size, 98 | fitType: fitType, 99 | reduceValue: reduceValue, 100 | calcResultType: .globalConfig 101 | ) 102 | } 103 | 104 | /// 适配方法 105 | /// - Parameters: 106 | /// - size: 大小 107 | /// - fitType: 适配方式 108 | /// - reduceValue: 要额外减少的数值 109 | /// - calcResultType: 计算结果类型(默认: 跟随全局配置) 110 | /// - Returns: 适配后的数值 111 | @objc public static func fit( 112 | size: CGFloat, 113 | fitType: SwiftyFitType, 114 | reduceValue: CGFloat = 0, 115 | calcResultType: SwiftyFitCalcResultType = .globalConfig 116 | ) -> CGFloat { 117 | return Self.shared.fitNumberSize( 118 | size, 119 | fitType: fitType, 120 | reduceValue: reduceValue, 121 | calcResultType: calcResultType 122 | ) 123 | } 124 | 125 | /// 适配方法 126 | /// - Parameters: 127 | /// - size: 大小 128 | /// - fitType: 适配方式 129 | /// - referenceWidth: 参照的宽度 130 | /// - referenceHeight: 参照的高度 131 | /// - isIPhoneXSeriesHeight: 参照的高度是否为iPhoneX系列 132 | /// - reduceValue: 要额外减少的数值 133 | /// - calcResultType: 计算结果类型(默认: 跟随全局配置) 134 | /// - Returns: 适配后的数值 135 | @objc public static func fit( 136 | size: CGFloat, 137 | fitType: SwiftyFitType, 138 | referenceWidth: CGFloat = SwiftyFitsize.shared.referenceW, 139 | referenceHeight: CGFloat = SwiftyFitsize.shared.referenceH, 140 | isIPhoneXSeriesHeight: Bool = SwiftyFitsize.shared.isIPhoneXSeriesHeight, 141 | reduceValue: CGFloat = 0, 142 | calcResultType: SwiftyFitCalcResultType = .globalConfig 143 | ) -> CGFloat { 144 | return Self.shared.fitNumberSize( 145 | size, 146 | fitType: fitType, 147 | referenceWidth: referenceWidth, 148 | referenceHeight: referenceHeight, 149 | isIPhoneXSeriesHeight: isIPhoneXSeriesHeight, 150 | reduceValue: reduceValue, 151 | calcResultType: calcResultType 152 | ) 153 | } 154 | 155 | /// 适配的核心计算方法 156 | /// - Parameters: 157 | /// - value: 需要适配的数值 158 | /// - fitType: 适配方式 159 | /// - referenceWidth: 参照的宽度 160 | /// - referenceHeight: 参照的高度 161 | /// - isIPhoneXSeriesHeight: 参照的高度是否为iPhoneX系列 162 | /// - reduceValue: 减少的数值(默认: 0) 163 | /// - calcResultType: 计算结果类型(默认: 跟随全局配置) 164 | /// - Returns: 适配后的数值 165 | fileprivate func fitNumberSize( 166 | _ value: CGFloat, 167 | fitType: SwiftyFitType, 168 | referenceWidth: CGFloat = SwiftyFitsize.shared.referenceW, 169 | referenceHeight: CGFloat = SwiftyFitsize.shared.referenceH, 170 | isIPhoneXSeriesHeight: Bool = SwiftyFitsize.shared.isIPhoneXSeriesHeight, 171 | reduceValue: CGFloat = 0, 172 | calcResultType: SwiftyFitCalcResultType = .globalConfig 173 | ) -> CGFloat { 174 | var calcResult: CGFloat 175 | 176 | switch fitType { 177 | case .none: return value 178 | case .flexibleWidth: 179 | let currentWidth = Config.Screen.width - reduceValue 180 | let finalReferenceW = referenceWidth - reduceValue 181 | calcResult = currentWidth / finalReferenceW * value * fitMultiple 182 | case .forceWidth: 183 | let currentWidth = Config.Screen.width - reduceValue 184 | let finalReferenceW = referenceWidth - reduceValue 185 | calcResult = currentWidth / finalReferenceW * value 186 | case .flexibleHeight: 187 | let currentHeight = Config.Screen.height - reduceValue 188 | let finalReferenceH = referenceHeight - reduceValue 189 | calcResult = currentHeight / finalReferenceH * value * fitMultiple 190 | case .forceHeight: 191 | let currentHeight = Config.Screen.height - reduceValue 192 | let finalReferenceH = referenceHeight - reduceValue 193 | calcResult = currentHeight / finalReferenceH * value 194 | case .flexibleSafeAreaCenterHeight: 195 | let referenceSafeAreaCenterHeight = self.fetchReferenceSafeAreaCenterHeight( 196 | isIPhoneXSeriesHeight: isIPhoneXSeriesHeight, 197 | referenceHeight: referenceHeight 198 | ) 199 | let currentHeight = Config.Screen.iPhoneXSeriesSafeAreaCenterHeight - reduceValue 200 | let finalReferenceH = referenceSafeAreaCenterHeight - reduceValue 201 | calcResult = currentHeight / finalReferenceH * value * fitMultiple 202 | case .forceSafeAreaCenterHeight: 203 | let referenceSafeAreaCenterHeight = self.fetchReferenceSafeAreaCenterHeight( 204 | isIPhoneXSeriesHeight: isIPhoneXSeriesHeight, 205 | referenceHeight: referenceHeight 206 | ) 207 | let currentHeight = Config.Screen.iPhoneXSeriesSafeAreaCenterHeight - reduceValue 208 | let finalReferenceH = referenceSafeAreaCenterHeight - reduceValue 209 | calcResult = currentHeight / finalReferenceH * value 210 | case .flexibleSafeAreaWithoutTopHeight: 211 | let referenceSafeAreaWithoutTopHeight = self.fetchReferenceSafeAreaWithoutTopHeight( 212 | isIPhoneXSeriesHeight: isIPhoneXSeriesHeight, 213 | referenceHeight: referenceHeight 214 | ) 215 | let currentHeight = Config.Screen.iPhoneXSeriesSafeAreaWithoutTopHeight - reduceValue 216 | let finalReferenceH = referenceSafeAreaWithoutTopHeight - reduceValue 217 | calcResult = currentHeight / finalReferenceH * value * fitMultiple 218 | case .forceSafeAreaWithoutTopHeight: 219 | let referenceSafeAreaWithoutTopHeight = self.fetchReferenceSafeAreaWithoutTopHeight( 220 | isIPhoneXSeriesHeight: isIPhoneXSeriesHeight, 221 | referenceHeight: referenceHeight 222 | ) 223 | let currentHeight = Config.Screen.iPhoneXSeriesSafeAreaWithoutTopHeight - reduceValue 224 | let finalReferenceH = referenceSafeAreaWithoutTopHeight - reduceValue 225 | calcResult = currentHeight / finalReferenceH * value 226 | } 227 | 228 | // 根据指定的计算结果类型计算最终的值 229 | let finalCalcResultType: SwiftyFitCalcResultType 230 | if calcResultType == .globalConfig { 231 | finalCalcResultType = SwiftyFitsize.shared.calcResultType 232 | } else { 233 | finalCalcResultType = calcResultType 234 | } 235 | switch finalCalcResultType { 236 | case .globalConfig, .raw: // 原始数据 237 | break 238 | case .round: // 四舍五入 239 | calcResult = round(calcResult) 240 | case .oneDecimalPlace: // 保留一位小数 241 | calcResult = round(calcResult * 10) / 10 242 | } 243 | 244 | return calcResult 245 | } 246 | 247 | fileprivate func fitFontSize( 248 | _ font : UIFont, 249 | type: SwiftyFitType 250 | ) -> UIFont { 251 | switch type { 252 | case .flexibleWidth: return font~ 253 | case .forceWidth: return font≈ 254 | case .flexibleHeight: return font∣ 255 | case .forceHeight: return font∥ 256 | case .flexibleSafeAreaCenterHeight: return font∣= 257 | case .forceSafeAreaCenterHeight: return font∥= 258 | case .flexibleSafeAreaWithoutTopHeight: return font∣- 259 | case .forceSafeAreaWithoutTopHeight: return font∥- 260 | default: return font 261 | } 262 | } 263 | 264 | /// 获取中间安全区域参照高度 265 | fileprivate func fetchReferenceSafeAreaCenterHeight( 266 | isIPhoneXSeriesHeight: Bool = SwiftyFitsize.shared.isIPhoneXSeriesHeight, 267 | referenceHeight: CGFloat = SwiftyFitsize.shared.referenceH 268 | ) -> CGFloat { 269 | if !isIPhoneXSeriesHeight { return referenceHeight } 270 | return referenceHeight - Config.Screen.safeAreaTopMargin - Config.Screen.safeAreaBottomMargin 271 | } 272 | 273 | /// 获取仅去除顶部后的安全区域参照高度 274 | fileprivate func fetchReferenceSafeAreaWithoutTopHeight( 275 | isIPhoneXSeriesHeight: Bool = SwiftyFitsize.shared.isIPhoneXSeriesHeight, 276 | referenceHeight: CGFloat = SwiftyFitsize.shared.referenceH 277 | ) -> CGFloat { 278 | if !isIPhoneXSeriesHeight { return referenceHeight } 279 | return referenceHeight - Config.Screen.safeAreaTopMargin 280 | } 281 | } 282 | 283 | // MARK:- 运算符 284 | 285 | // MARK: operator ~ 286 | postfix operator ~ 287 | public postfix func ~ (value: CGFloat) -> CGFloat { 288 | return value.sf(.flexibleWidth) 289 | } 290 | public postfix func ~ (font: UIFont) -> UIFont { 291 | return font.sf(.flexibleWidth) 292 | } 293 | public postfix func ~ (value: Int) -> CGFloat { 294 | return CGFloat(value).sf(.flexibleWidth) 295 | } 296 | public postfix func ~ (value: Float) -> CGFloat { 297 | return CGFloat(value).sf(.flexibleWidth) 298 | } 299 | public postfix func ~ (value: CGPoint) -> CGPoint { 300 | return value.sf(.flexibleWidth) 301 | } 302 | public postfix func ~ (value: CGSize) -> CGSize { 303 | return value.sf(.flexibleWidth) 304 | } 305 | public postfix func ~ (value: CGRect) -> CGRect { 306 | return value.sf(.flexibleWidth) 307 | } 308 | public postfix func ~ (value: UIEdgeInsets) -> UIEdgeInsets { 309 | return value.sf(.flexibleWidth) 310 | } 311 | 312 | // MARK: operator ≈ 313 | postfix operator ≈ 314 | public postfix func ≈ (value: CGFloat) -> CGFloat { 315 | return value.sf(.forceWidth) 316 | } 317 | public postfix func ≈ (font: UIFont) -> UIFont { 318 | return font.sf(.forceWidth) 319 | } 320 | public postfix func ≈ (value: Int) -> CGFloat { 321 | return CGFloat(value).sf(.forceWidth) 322 | } 323 | public postfix func ≈ (value: Float) -> CGFloat { 324 | return CGFloat(value).sf(.forceWidth) 325 | } 326 | public postfix func ≈ (value: CGPoint) -> CGPoint { 327 | return value.sf(.forceWidth) 328 | } 329 | public postfix func ≈ (value: CGSize) -> CGSize { 330 | return value.sf(.forceWidth) 331 | } 332 | public postfix func ≈ (value: CGRect) -> CGRect { 333 | return value.sf(.forceWidth) 334 | } 335 | public postfix func ≈ (value: UIEdgeInsets) -> UIEdgeInsets { 336 | return value.sf(.forceWidth) 337 | } 338 | 339 | // MARK: operator ∣ 340 | postfix operator ∣ 341 | public postfix func ∣ (value: CGFloat) -> CGFloat { 342 | return value.sf(.flexibleHeight) 343 | } 344 | public postfix func ∣ (font: UIFont) -> UIFont { 345 | return font.sf(.flexibleHeight) 346 | } 347 | public postfix func ∣ (value: Int) -> CGFloat { 348 | return CGFloat(value).sf(.flexibleHeight) 349 | } 350 | public postfix func ∣ (value: Float) -> CGFloat { 351 | return CGFloat(value).sf(.flexibleHeight) 352 | } 353 | public postfix func ∣ (value: CGPoint) -> CGPoint { 354 | return value.sf(.flexibleHeight) 355 | } 356 | public postfix func ∣ (value: CGSize) -> CGSize { 357 | return value.sf(.flexibleHeight) 358 | } 359 | public postfix func ∣ (value: CGRect) -> CGRect { 360 | return value.sf(.flexibleHeight) 361 | } 362 | public postfix func ∣ (value: UIEdgeInsets) -> UIEdgeInsets { 363 | return value.sf(.flexibleHeight) 364 | } 365 | 366 | // MARK: operator ∥ 367 | postfix operator ∥ 368 | public postfix func ∥ (value: CGFloat) -> CGFloat { 369 | return value.sf(.forceHeight) 370 | } 371 | public postfix func ∥ (font: UIFont) -> UIFont { 372 | return font.sf(.forceHeight) 373 | } 374 | public postfix func ∥ (value: Int) -> CGFloat { 375 | return CGFloat(value).sf(.forceHeight) 376 | } 377 | public postfix func ∥ (value: Float) -> CGFloat { 378 | return CGFloat(value).sf(.forceHeight) 379 | } 380 | public postfix func ∥ (value: CGPoint) -> CGPoint { 381 | return value.sf(.forceHeight) 382 | } 383 | public postfix func ∥ (value: CGSize) -> CGSize { 384 | return value.sf(.forceHeight) 385 | } 386 | public postfix func ∥ (value: CGRect) -> CGRect { 387 | return value.sf(.forceHeight) 388 | } 389 | public postfix func ∥ (value: UIEdgeInsets) -> UIEdgeInsets { 390 | return value.sf(.forceHeight) 391 | } 392 | 393 | // MARK: operator ∣= 394 | postfix operator ∣= 395 | public postfix func ∣= (value: CGFloat) -> CGFloat { 396 | return value.sf(.flexibleSafeAreaCenterHeight) 397 | } 398 | public postfix func ∣= (font: UIFont) -> UIFont { 399 | return font.sf(.flexibleSafeAreaCenterHeight) 400 | } 401 | public postfix func ∣= (value: Int) -> CGFloat { 402 | return CGFloat(value).sf(.flexibleSafeAreaCenterHeight) 403 | } 404 | public postfix func ∣= (value: Float) -> CGFloat { 405 | return CGFloat(value).sf(.flexibleSafeAreaCenterHeight) 406 | } 407 | public postfix func ∣= (value: CGPoint) -> CGPoint { 408 | return value.sf(.flexibleSafeAreaCenterHeight) 409 | } 410 | public postfix func ∣= (value: CGSize) -> CGSize { 411 | return value.sf(.flexibleSafeAreaCenterHeight) 412 | } 413 | public postfix func ∣= (value: CGRect) -> CGRect { 414 | return value.sf(.flexibleSafeAreaCenterHeight) 415 | } 416 | public postfix func ∣= (value: UIEdgeInsets) -> UIEdgeInsets { 417 | return value.sf(.flexibleSafeAreaCenterHeight) 418 | } 419 | 420 | // MARK: operator ∥= 421 | postfix operator ∥= 422 | public postfix func ∥= (value: CGFloat) -> CGFloat { 423 | return value.sf(.forceSafeAreaCenterHeight) 424 | } 425 | public postfix func ∥= (font: UIFont) -> UIFont { 426 | return font.sf(.forceSafeAreaCenterHeight) 427 | } 428 | public postfix func ∥= (value: Int) -> CGFloat { 429 | return CGFloat(value).sf(.forceSafeAreaCenterHeight) 430 | } 431 | public postfix func ∥= (value: Float) -> CGFloat { 432 | return CGFloat(value).sf(.forceSafeAreaCenterHeight) 433 | } 434 | public postfix func ∥= (value: CGPoint) -> CGPoint { 435 | return value.sf(.forceSafeAreaCenterHeight) 436 | } 437 | public postfix func ∥= (value: CGSize) -> CGSize { 438 | return value.sf(.forceSafeAreaCenterHeight) 439 | } 440 | public postfix func ∥= (value: CGRect) -> CGRect { 441 | return value.sf(.forceSafeAreaCenterHeight) 442 | } 443 | public postfix func ∥= (value: UIEdgeInsets) -> UIEdgeInsets { 444 | return value.sf(.forceSafeAreaCenterHeight) 445 | } 446 | 447 | // MARK: operator ∣- 448 | postfix operator ∣- 449 | public postfix func ∣- (value: CGFloat) -> CGFloat { 450 | return value.sf(.flexibleSafeAreaWithoutTopHeight) 451 | } 452 | public postfix func ∣- (font: UIFont) -> UIFont { 453 | return font.sf(.flexibleSafeAreaWithoutTopHeight) 454 | } 455 | public postfix func ∣- (value: Int) -> CGFloat { 456 | return CGFloat(value).sf(.flexibleSafeAreaWithoutTopHeight) 457 | } 458 | public postfix func ∣- (value: Float) -> CGFloat { 459 | return CGFloat(value).sf(.flexibleSafeAreaWithoutTopHeight) 460 | } 461 | public postfix func ∣- (value: CGPoint) -> CGPoint { 462 | return value.sf(.flexibleSafeAreaWithoutTopHeight) 463 | } 464 | public postfix func ∣- (value: CGSize) -> CGSize { 465 | return value.sf(.flexibleSafeAreaWithoutTopHeight) 466 | } 467 | public postfix func ∣- (value: CGRect) -> CGRect { 468 | return value.sf(.flexibleSafeAreaWithoutTopHeight) 469 | } 470 | public postfix func ∣- (value: UIEdgeInsets) -> UIEdgeInsets { 471 | return value.sf(.flexibleSafeAreaWithoutTopHeight) 472 | } 473 | 474 | // MARK: operator ∥- 475 | postfix operator ∥- 476 | public postfix func ∥- (value: CGFloat) -> CGFloat { 477 | return value.sf(.forceSafeAreaWithoutTopHeight) 478 | } 479 | public postfix func ∥- (font: UIFont) -> UIFont { 480 | return font.sf(.forceSafeAreaWithoutTopHeight) 481 | } 482 | public postfix func ∥- (value: Int) -> CGFloat { 483 | return CGFloat(value).sf(.forceSafeAreaWithoutTopHeight) 484 | } 485 | public postfix func ∥- (value: Float) -> CGFloat { 486 | return CGFloat(value).sf(.forceSafeAreaWithoutTopHeight) 487 | } 488 | public postfix func ∥- (value: CGPoint) -> CGPoint { 489 | return value.sf(.forceSafeAreaWithoutTopHeight) 490 | } 491 | public postfix func ∥- (value: CGSize) -> CGSize { 492 | return value.sf(.forceSafeAreaWithoutTopHeight) 493 | } 494 | public postfix func ∥- (value: CGRect) -> CGRect { 495 | return value.sf(.forceSafeAreaWithoutTopHeight) 496 | } 497 | public postfix func ∥- (value: UIEdgeInsets) -> UIEdgeInsets { 498 | return value.sf(.forceSafeAreaWithoutTopHeight) 499 | } 500 | 501 | // MARK:- 辅助拓展 502 | extension CGFloat { 503 | func sf(_ type: SwiftyFitType) -> CGFloat { 504 | return SwiftyFitsize.shared.fitNumberSize(self, fitType: type) 505 | } 506 | } 507 | extension UIFont { 508 | func sf(_ type: SwiftyFitType) -> UIFont { 509 | return self.withSize(self.pointSize.sf(type)) 510 | } 511 | } 512 | extension CGPoint { 513 | func sf(_ type: SwiftyFitType) -> CGPoint { 514 | return CGPoint(x: x.sf(type), y: y.sf(type)) 515 | } 516 | } 517 | extension CGSize { 518 | func sf(_ type: SwiftyFitType) -> CGSize { 519 | return CGSize(width: width.sf(type), height: height.sf(type)) 520 | } 521 | } 522 | extension CGRect { 523 | func sf(_ type: SwiftyFitType) -> CGRect { 524 | return CGRect( 525 | x: origin.x.sf(type), 526 | y: origin.y.sf(type), 527 | width: size.width.sf(type), 528 | height: size.height.sf(type) 529 | ) 530 | } 531 | } 532 | extension UIEdgeInsets { 533 | func sf(_ type: SwiftyFitType) -> UIEdgeInsets { 534 | return UIEdgeInsets( 535 | top: top.sf(type), 536 | left: left.sf(type), 537 | bottom: bottom.sf(type), 538 | right: right.sf(type) 539 | ) 540 | } 541 | } 542 | 543 | // MARK:- Xib/Storyboard 544 | public extension NSLayoutConstraint { 545 | @IBInspectable var swiftyFitType: Int { 546 | get { return SwiftyFitType.none.rawValue } 547 | set { 548 | guard let type = SwiftyFitType(rawValue: newValue) else { return } 549 | constant = SwiftyFitsize.shared.fitNumberSize(constant, fitType: type) 550 | } 551 | } 552 | } 553 | public extension UILabel { 554 | @IBInspectable var fontFitType: Int { 555 | get { return SwiftyFitType.none.rawValue } 556 | set { 557 | guard let type = SwiftyFitType(rawValue: newValue) else { return } 558 | guard let xfont = font else { return } 559 | self.font = SwiftyFitsize.shared.fitFontSize(xfont, type: type) 560 | } 561 | } 562 | } 563 | public extension UITextView { 564 | @IBInspectable var fontFitType: Int { 565 | get { return SwiftyFitType.none.rawValue } 566 | set { 567 | guard let type = SwiftyFitType(rawValue: newValue) else { return } 568 | guard let xfont = font else { return } 569 | self.font = SwiftyFitsize.shared.fitFontSize(xfont, type: type) 570 | } 571 | } 572 | } 573 | public extension UITextField { 574 | @IBInspectable var fontFitType: Int { 575 | get { return SwiftyFitType.none.rawValue } 576 | set { 577 | guard let type = SwiftyFitType(rawValue: newValue) else { return } 578 | guard let xfont = font else { return } 579 | self.font = SwiftyFitsize.shared.fitFontSize(xfont, type: type) 580 | } 581 | } 582 | } 583 | public extension UIButton { 584 | @IBInspectable var fontFitType: Int { 585 | get { return SwiftyFitType.none.rawValue } 586 | set { 587 | guard let type = SwiftyFitType(rawValue: newValue) else { return } 588 | guard let xfont = titleLabel?.font else { return } 589 | self.titleLabel?.font = SwiftyFitsize.shared.fitFontSize(xfont, type: type) 590 | } 591 | } 592 | } 593 | 594 | 595 | // MARK:- OC 596 | public extension UIFont { 597 | @objc var sf: UIFont { return self~ } 598 | @objc var sfz: UIFont { return self≈ } 599 | @objc var sf_fh: UIFont { return self∣ } 600 | @objc var sfz_fh: UIFont { return self∥ } 601 | @objc var sf_sch: UIFont { return self∣= } 602 | @objc var sfz_sch: UIFont { return self∥= } 603 | @objc var sf_sbh: UIFont { return self∣- } 604 | @objc var sfz_sbh: UIFont { return self∥- } 605 | } 606 | public extension SwiftyFitsize { 607 | @objc func sf_int(_ value: Int) -> CGFloat { 608 | return value~ 609 | } 610 | @objc func sf_float(_ value: CGFloat) -> CGFloat { 611 | return value~ 612 | } 613 | @objc func sf_point(_ value: CGPoint) -> CGPoint { 614 | return value~ 615 | } 616 | @objc func sf_size(_ value: CGSize) -> CGSize { 617 | return value~ 618 | } 619 | @objc func sf_rect(_ value: CGRect) -> CGRect { 620 | return value~ 621 | } 622 | @objc func sf_EdgeInsets(_ value: UIEdgeInsets) -> UIEdgeInsets { 623 | return value~ 624 | } 625 | 626 | @objc func sfz_int(_ value: Int) -> CGFloat { 627 | return value≈ 628 | } 629 | @objc func sfz_float(_ value: CGFloat) -> CGFloat { 630 | return value≈ 631 | } 632 | @objc func sfz_point(_ value: CGPoint) -> CGPoint { 633 | return value≈ 634 | } 635 | @objc func sfz_size(_ value: CGSize) -> CGSize { 636 | return value≈ 637 | } 638 | @objc func sfz_rect(_ value: CGRect) -> CGRect { 639 | return value≈ 640 | } 641 | @objc func sfz_EdgeInsets(_ value: UIEdgeInsets) -> UIEdgeInsets { 642 | return value≈ 643 | } 644 | 645 | // fh: full height 646 | @objc func sf_fh_int(_ value: Int) -> CGFloat { 647 | return value∣ 648 | } 649 | @objc func sf_fh_float(_ value: CGFloat) -> CGFloat { 650 | return value∣ 651 | } 652 | @objc func sf_fh_point(_ value: CGPoint) -> CGPoint { 653 | return value∣ 654 | } 655 | @objc func sf_fh_size(_ value: CGSize) -> CGSize { 656 | return value∣ 657 | } 658 | @objc func sf_fh_rect(_ value: CGRect) -> CGRect { 659 | return value∣ 660 | } 661 | @objc func sf_fh_EdgeInsets(_ value: UIEdgeInsets) -> UIEdgeInsets { 662 | return value∣ 663 | } 664 | 665 | @objc func sfz_fh_int(_ value: Int) -> CGFloat { 666 | return value∥ 667 | } 668 | @objc func sfz_fh_float(_ value: CGFloat) -> CGFloat { 669 | return value∥ 670 | } 671 | @objc func sfz_fh_point(_ value: CGPoint) -> CGPoint { 672 | return value∥ 673 | } 674 | @objc func sfz_fh_size(_ value: CGSize) -> CGSize { 675 | return value∥ 676 | } 677 | @objc func sfz_fh_rect(_ value: CGRect) -> CGRect { 678 | return value∥ 679 | } 680 | @objc func sfz_fh_EdgeInsets(_ value: UIEdgeInsets) -> UIEdgeInsets { 681 | return value∥ 682 | } 683 | 684 | // sch: safeArea center height 685 | @objc func sf_sch_int(_ value: Int) -> CGFloat { 686 | return value∣= 687 | } 688 | @objc func sf_sch_float(_ value: CGFloat) -> CGFloat { 689 | return value∣= 690 | } 691 | @objc func sf_sch_point(_ value: CGPoint) -> CGPoint { 692 | return value∣= 693 | } 694 | @objc func sf_sch_size(_ value: CGSize) -> CGSize { 695 | return value∣= 696 | } 697 | @objc func sf_sch_rect(_ value: CGRect) -> CGRect { 698 | return value∣= 699 | } 700 | @objc func sf_sch_EdgeInsets(_ value: UIEdgeInsets) -> UIEdgeInsets { 701 | return value∣= 702 | } 703 | 704 | @objc func sfz_sch_int(_ value: Int) -> CGFloat { 705 | return value∥= 706 | } 707 | @objc func sfz_sch_float(_ value: CGFloat) -> CGFloat { 708 | return value∥= 709 | } 710 | @objc func sfz_sch_point(_ value: CGPoint) -> CGPoint { 711 | return value∥= 712 | } 713 | @objc func sfz_sch_size(_ value: CGSize) -> CGSize { 714 | return value∥= 715 | } 716 | @objc func sfz_sch_rect(_ value: CGRect) -> CGRect { 717 | return value∥= 718 | } 719 | @objc func sfz_sch_EdgeInsets(_ value: UIEdgeInsets) -> UIEdgeInsets { 720 | return value∥= 721 | } 722 | 723 | // sbh: safeArea bottom height 724 | @objc func sf_sbh_int(_ value: Int) -> CGFloat { 725 | return value∣- 726 | } 727 | @objc func sf_sbh_float(_ value: CGFloat) -> CGFloat { 728 | return value∣- 729 | } 730 | @objc func sf_sbh_point(_ value: CGPoint) -> CGPoint { 731 | return value∣- 732 | } 733 | @objc func sf_sbh_size(_ value: CGSize) -> CGSize { 734 | return value∣- 735 | } 736 | @objc func sf_sbh_rect(_ value: CGRect) -> CGRect { 737 | return value∣- 738 | } 739 | @objc func sf_sbh_EdgeInsets(_ value: UIEdgeInsets) -> UIEdgeInsets { 740 | return value∣- 741 | } 742 | 743 | @objc func sfz_sbh_int(_ value: Int) -> CGFloat { 744 | return value∥- 745 | } 746 | @objc func sfz_sbh_float(_ value: CGFloat) -> CGFloat { 747 | return value∥- 748 | } 749 | @objc func sfz_sbh_point(_ value: CGPoint) -> CGPoint { 750 | return value∥- 751 | } 752 | @objc func sfz_sbh_size(_ value: CGSize) -> CGSize { 753 | return value∥- 754 | } 755 | @objc func sfz_sbh_rect(_ value: CGRect) -> CGRect { 756 | return value∥- 757 | } 758 | @objc func sfz_sbh_EdgeInsets(_ value: UIEdgeInsets) -> UIEdgeInsets { 759 | return value∥- 760 | } 761 | } 762 | -------------------------------------------------------------------------------- /Sources/SwiftyFitsize/SwiftyFitsizeConfig.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftyFitsizeConfig.swift 3 | // SwiftyFitsize 4 | // 5 | // Created by LinXunFeng on 2021/8/21. 6 | // 7 | 8 | import CoreGraphics 9 | import Foundation 10 | import UIKit 11 | 12 | // MARK:- Config 13 | extension SwiftyFitsize { 14 | public struct Config { 15 | // MARK: Screen 16 | public struct Screen { 17 | private static let sw: CGFloat = UIScreen.main.bounds.width 18 | private static let sh: CGFloat = UIScreen.main.bounds.height 19 | 20 | public static let width: CGFloat = sw < sh ? sw : sh 21 | public static let height: CGFloat = sw < sh ? sh : sw 22 | 23 | public static var safeAreaTopMargin: CGFloat { 24 | return Device.getSafeAreaTopMargin() 25 | } 26 | public static var safeAreaBottomMargin: CGFloat { 27 | Device.getSafeAreaBottomMargin() 28 | } 29 | public static var iPhoneXSeriesSafeAreaCenterHeight: CGFloat { 30 | return height - safeAreaTopMargin - safeAreaBottomMargin 31 | } 32 | public static var iPhoneXSeriesSafeAreaWithoutTopHeight: CGFloat { 33 | return height - safeAreaTopMargin 34 | } 35 | } 36 | 37 | // MARK: Device 38 | public struct Device { 39 | public static let isIPad = UIDevice.current.userInterfaceIdiom == UIUserInterfaceIdiom.pad 40 | public static let isIphneXSeries = isIPhoneXSeries() 41 | 42 | public static func getCurrentWindow() -> UIWindow? { 43 | if let window = UIApplication.shared.delegate?.window { 44 | return window 45 | } 46 | if #available(iOS 13.0, *) { 47 | if let window = (UIApplication.shared.connectedScenes.first as? UIWindowScene)?.windows.first { 48 | return window 49 | } 50 | } 51 | return UIApplication.shared.keyWindow 52 | } 53 | 54 | /// 是否是iphoneX系列 55 | public static func isIPhoneXSeries() -> Bool { 56 | var bottomSafeInset: CGFloat = 0 57 | if #available(iOS 11.0, *) { 58 | bottomSafeInset = getCurrentWindow()?.safeAreaInsets.bottom ?? 0 59 | } 60 | return bottomSafeInset > 0 61 | } 62 | 63 | /// 当前是否是竖屏 64 | public static func isPortrait() -> Bool { 65 | return UIApplication.shared.statusBarOrientation.isPortrait 66 | } 67 | 68 | public static func getSafeAreaInsets() -> UIEdgeInsets { 69 | var safeAreaInsets: UIEdgeInsets = .zero 70 | if #available(iOS 11.0, *) { 71 | guard let inset = getCurrentWindow()?.safeAreaInsets else { return .zero } 72 | safeAreaInsets = inset 73 | } 74 | return safeAreaInsets 75 | } 76 | 77 | /// 安全区域刘海一侧的间距 78 | public static func getSafeAreaTopMargin() -> CGFloat { 79 | let inset = getSafeAreaInsets() 80 | switch UIApplication.shared.statusBarOrientation { 81 | case .portrait, .portraitUpsideDown: return inset.top 82 | case .landscapeLeft: return inset.right 83 | case .landscapeRight: return inset.left 84 | default: return 0 85 | } 86 | } 87 | 88 | /// 安全区域刘海对侧的间距 89 | public static func getSafeAreaBottomMargin() -> CGFloat { 90 | let inset = getSafeAreaInsets() 91 | switch UIApplication.shared.statusBarOrientation { 92 | case .portrait, .portraitUpsideDown: return inset.bottom 93 | case .landscapeLeft: return inset.left 94 | case .landscapeRight: return inset.right 95 | default: return 0 96 | } 97 | } 98 | } 99 | } 100 | } 101 | 102 | -------------------------------------------------------------------------------- /Sources/SwiftyFitsize/SwiftyFitsizeHeader.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftyFitsizeHeader.swift 3 | // Pods 4 | // 5 | // Created by LinXunFeng on 2021/10/16. 6 | // 7 | 8 | import Foundation 9 | 10 | /* 11 | * ~ : 对比宽度,当设备为iPad时,适配后的 value 会再乘上 iPadFitMultiple 12 | * ≈ : 对比宽度,强制适配,不论是iPhone还是iPad 都不会乘上 iPadFitMultiple 13 | * ∣ : 对比高度,对应 ~ ,整屏高度 14 | * ∥ : 对比高度,对应 ≈ ,整屏高度 15 | * ∣= : 对比高度,对应 ∣ ,安全区域内的高度 16 | * ∥= : 对比高度,对应 ∥ ,安全区域内的高度 17 | * ∣- : 对比高度,对应 ∣ ,除去刘海区域的安全区域内的高度 18 | * ∥- : 对比高度,对应 ∥ ,除去刘海区域的安全区域内的高度 19 | */ 20 | 21 | @objc public enum SwiftyFitType: Int { 22 | /// Original Value 23 | case none = 0 24 | /// ~ 25 | case flexibleWidth = 1 26 | /// ≈ 27 | case forceWidth = 2 28 | /// ∣ 29 | case flexibleHeight = 3 30 | /// ∥ 31 | case forceHeight = 4 32 | /// ∣= 33 | case flexibleSafeAreaCenterHeight = 5 34 | /// ∥= 35 | case forceSafeAreaCenterHeight = 6 36 | /// ∣- 37 | case flexibleSafeAreaWithoutTopHeight = 7 38 | /// ∥- 39 | case forceSafeAreaWithoutTopHeight = 8 40 | } 41 | 42 | /// 计算结果类型 43 | @objc public enum SwiftyFitCalcResultType: Int { 44 | /// 跟随全局配置 45 | case globalConfig 46 | /// 原始数据 47 | case raw 48 | /// 四舍五入 49 | case round 50 | /// 保留一位小数(根据第二位小数进行四舍五入) 51 | case oneDecimalPlace 52 | } 53 | -------------------------------------------------------------------------------- /Sources/SwiftyFitsize/WrappedSwiftyFitsize.swift: -------------------------------------------------------------------------------- 1 | // 2 | // WrappedSwiftyFitsize.swift 3 | // SwiftyFitsize 4 | // 5 | // Created by LinXunFeng on 2021/8/21. 6 | // 7 | 8 | import CoreGraphics 9 | import Foundation 10 | 11 | @propertyWrapper 12 | public struct WrappedSwiftyFitsize { 13 | /// 最终计算好的数值 14 | private var value: CGFloat = 0 15 | /// 要减少的数值 16 | private var reduceValue: CGFloat 17 | /// 适配类型 18 | private let fitType: SwiftyFitType 19 | /// 指定的参照宽度(默认: 全局设置的值) 20 | private let referenceWidth: CGFloat 21 | /// 指定的参照高度(默认: 全局设置的值) 22 | private let referenceHeight: CGFloat 23 | /// 指定的参照亮度(默认: 全局设置的值) 24 | private let isIPhoneXSeriesHeight: Bool 25 | /// 计算结果类型 26 | private let calcResultType: SwiftyFitCalcResultType 27 | 28 | public lazy var projectedValue: ((CGFloat) -> CGFloat) = { 29 | return calcValue 30 | }() 31 | 32 | public var wrappedValue: CGFloat { 33 | get { 34 | return value 35 | } 36 | set { 37 | self.value = self.calcValue(with: newValue) 38 | } 39 | } 40 | 41 | public init( 42 | wrappedValue: CGFloat = 0, 43 | fitType: SwiftyFitType = .flexibleWidth, 44 | referenceWidth: CGFloat = SwiftyFitsize.shared.referenceW, 45 | referenceHeight: CGFloat = SwiftyFitsize.shared.referenceH, 46 | isIPhoneXSeriesHeight: Bool = SwiftyFitsize.shared.isIPhoneXSeriesHeight, 47 | reduceValue: CGFloat = 0, 48 | calcResultType: SwiftyFitCalcResultType = .globalConfig 49 | ) { 50 | self.reduceValue = reduceValue 51 | self.referenceWidth = referenceWidth 52 | self.referenceHeight = referenceHeight 53 | self.isIPhoneXSeriesHeight = isIPhoneXSeriesHeight 54 | self.fitType = fitType 55 | self.calcResultType = calcResultType 56 | self.value = self.calcValue(with: wrappedValue) 57 | } 58 | 59 | public func calcValue(with value: CGFloat) -> CGFloat { 60 | return SwiftyFitsize.fit( 61 | size: value, 62 | fitType: self.fitType, 63 | referenceWidth: self.referenceWidth, 64 | referenceHeight: self.referenceHeight, 65 | isIPhoneXSeriesHeight: isIPhoneXSeriesHeight, 66 | reduceValue: self.reduceValue, 67 | calcResultType: self.calcResultType 68 | ) 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /Sources/SwiftyFitsizeOCSupport/empty.c: -------------------------------------------------------------------------------- 1 | /* This file is intentionally left blank */ 2 | -------------------------------------------------------------------------------- /Sources/SwiftyFitsizeOCSupport/include/SwiftyFitsizeOCSupport/SwiftyFitsize.h: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftFitSizeOC.h 3 | // Pods 4 | // 5 | // Created by LinXunFeng on 2018/11/15. 6 | // 7 | 8 | #ifndef SwiftFitSizeOC_h 9 | #define SwiftFitSizeOC_h 10 | 11 | /** ================== ~ ================== */ 12 | 13 | #define SF_Font(font) \ 14 | font.sf 15 | 16 | #define SF_Int(value) \ 17 | [[SwiftyFitsize sharedSwiftyFitsize] sf_int:value] 18 | 19 | #define SF_Float(value) \ 20 | [[SwiftyFitsize sharedSwiftyFitsize] sf_float:value] 21 | 22 | #define SF_Point(value) \ 23 | [[SwiftyFitsize sharedSwiftyFitsize] sf_point:value] 24 | 25 | #define SF_Size(value) \ 26 | [[SwiftyFitsize sharedSwiftyFitsize] sf_size:value] 27 | 28 | #define SF_Rect(value) \ 29 | [[SwiftyFitsize sharedSwiftyFitsize] sf_rect:value] 30 | 31 | #define SF_EdgeInsets(value) \ 32 | [[SwiftyFitsize sharedSwiftyFitsize] sf_EdgeInsets:value] 33 | 34 | /** ================== ≈ ================== */ 35 | 36 | #define SFZ_Font(font) \ 37 | font.sfz 38 | 39 | #define SFZ_Int(value) \ 40 | [[SwiftyFitsize sharedSwiftyFitsize] sfz_int:value] 41 | 42 | #define SFZ_Float(value) \ 43 | [[SwiftyFitsize sharedSwiftyFitsize] sfz_float:value] 44 | 45 | #define SFZ_Point(value) \ 46 | [[SwiftyFitsize sharedSwiftyFitsize] sfz_point:value] 47 | 48 | #define SFZ_Size(value) \ 49 | [[SwiftyFitsize sharedSwiftyFitsize] sfz_size:value] 50 | 51 | #define SFZ_Rect(value) \ 52 | [[SwiftyFitsize sharedSwiftyFitsize] sfz_rect:value] 53 | 54 | #define SFZ_EdgeInsets(value) \ 55 | [[SwiftyFitsize sharedSwiftyFitsize] sfz_EdgeInsets:value] 56 | 57 | /** ================== ∣ ================== */ 58 | 59 | #define SF_FH_Font(font) \ 60 | font.sf_fh 61 | 62 | #define SF_FH_Int(value) \ 63 | [[SwiftyFitsize sharedSwiftyFitsize] sf_fh_int:value] 64 | 65 | #define SF_FH_Float(value) \ 66 | [[SwiftyFitsize sharedSwiftyFitsize] sf_fh_float:value] 67 | 68 | #define SF_FH_Point(value) \ 69 | [[SwiftyFitsize sharedSwiftyFitsize] sf_fh_point:value] 70 | 71 | #define SF_FH_Size(value) \ 72 | [[SwiftyFitsize sharedSwiftyFitsize] sf_fh_size:value] 73 | 74 | #define SF_FH_Rect(value) \ 75 | [[SwiftyFitsize sharedSwiftyFitsize] sf_fh_rect:value] 76 | 77 | #define SF_FH_EdgeInsets(value) \ 78 | [[SwiftyFitsize sharedSwiftyFitsize] sf_fh_EdgeInsets:value] 79 | 80 | /** ================== ∥ ================== */ 81 | 82 | #define SFZ_FH_Font(font) \ 83 | font.sfz_fh 84 | 85 | #define SFZ_FH_Int(value) \ 86 | [[SwiftyFitsize sharedSwiftyFitsize] sfz_fh_int:value] 87 | 88 | #define SFZ_FH_Float(value) \ 89 | [[SwiftyFitsize sharedSwiftyFitsize] sfz_fh_float:value] 90 | 91 | #define SFZ_FH_Point(value) \ 92 | [[SwiftyFitsize sharedSwiftyFitsize] sfz_fh_point:value] 93 | 94 | #define SFZ_FH_Size(value) \ 95 | [[SwiftyFitsize sharedSwiftyFitsize] sfz_fh_size:value] 96 | 97 | #define SFZ_FH_Rect(value) \ 98 | [[SwiftyFitsize sharedSwiftyFitsize] sfz_fh_rect:value] 99 | 100 | #define SFZ_FH_EdgeInsets(value) \ 101 | [[SwiftyFitsize sharedSwiftyFitsize] sfz_fh_EdgeInsets:value] 102 | 103 | /** ================== ∣= ================== */ 104 | 105 | #define SF_SCH_Font(font) \ 106 | font.sf_sch 107 | 108 | #define SF_SCH_Int(value) \ 109 | [[SwiftyFitsize sharedSwiftyFitsize] sf_sch_int:value] 110 | 111 | #define SF_SCH_Float(value) \ 112 | [[SwiftyFitsize sharedSwiftyFitsize] sf_sch_float:value] 113 | 114 | #define SF_SCH_Point(value) \ 115 | [[SwiftyFitsize sharedSwiftyFitsize] sf_sch_point:value] 116 | 117 | #define SF_SCH_Size(value) \ 118 | [[SwiftyFitsize sharedSwiftyFitsize] sf_sch_size:value] 119 | 120 | #define SF_SCH_Rect(value) \ 121 | [[SwiftyFitsize sharedSwiftyFitsize] sf_sch_rect:value] 122 | 123 | #define SF_SCH_EdgeInsets(value) \ 124 | [[SwiftyFitsize sharedSwiftyFitsize] sf_sch_EdgeInsets:value] 125 | 126 | /** ================== ∥= ================== */ 127 | 128 | #define SFZ_SCH_Font(font) \ 129 | font.sfz_sch 130 | 131 | #define SFZ_SCH_Int(value) \ 132 | [[SwiftyFitsize sharedSwiftyFitsize] sfz_sch_int:value] 133 | 134 | #define SFZ_SCH_Float(value) \ 135 | [[SwiftyFitsize sharedSwiftyFitsize] sfz_sch_float:value] 136 | 137 | #define SFZ_SCH_Point(value) \ 138 | [[SwiftyFitsize sharedSwiftyFitsize] sfz_sch_point:value] 139 | 140 | #define SFZ_SCH_Size(value) \ 141 | [[SwiftyFitsize sharedSwiftyFitsize] sfz_sch_size:value] 142 | 143 | #define SFZ_SCH_Rect(value) \ 144 | [[SwiftyFitsize sharedSwiftyFitsize] sfz_sch_rect:value] 145 | 146 | #define SFZ_SCH_EdgeInsets(value) \ 147 | [[SwiftyFitsize sharedSwiftyFitsize] sfz_sch_EdgeInsets:value] 148 | 149 | /** ================== ∣- ================== */ 150 | 151 | #define SF_SBH_Font(font) \ 152 | font.sf_sbh 153 | 154 | #define SF_SBH_Int(value) \ 155 | [[SwiftyFitsize sharedSwiftyFitsize] sf_sbh_int:value] 156 | 157 | #define SF_SBH_Float(value) \ 158 | [[SwiftyFitsize sharedSwiftyFitsize] sf_sbh_float:value] 159 | 160 | #define SF_SBH_Point(value) \ 161 | [[SwiftyFitsize sharedSwiftyFitsize] sf_sbh_point:value] 162 | 163 | #define SF_SBH_Size(value) \ 164 | [[SwiftyFitsize sharedSwiftyFitsize] sf_sbh_size:value] 165 | 166 | #define SF_SBH_Rect(value) \ 167 | [[SwiftyFitsize sharedSwiftyFitsize] sf_sbh_rect:value] 168 | 169 | #define SF_SBH_EdgeInsets(value) \ 170 | [[SwiftyFitsize sharedSwiftyFitsize] sf_sbh_EdgeInsets:value] 171 | 172 | /** ================== ∥= ================== */ 173 | 174 | #define SFZ_SBH_Font(font) \ 175 | font.sfz_sbh 176 | 177 | #define SFZ_SBH_Int(value) \ 178 | [[SwiftyFitsize sharedSwiftyFitsize] sfz_sbh_int:value] 179 | 180 | #define SFZ_SBH_Float(value) \ 181 | [[SwiftyFitsize sharedSwiftyFitsize] sfz_sbh_float:value] 182 | 183 | #define SFZ_SBH_Point(value) \ 184 | [[SwiftyFitsize sharedSwiftyFitsize] sfz_sbh_point:value] 185 | 186 | #define SFZ_SBH_Size(value) \ 187 | [[SwiftyFitsize sharedSwiftyFitsize] sfz_sbh_size:value] 188 | 189 | #define SFZ_SBH_Rect(value) \ 190 | [[SwiftyFitsize sharedSwiftyFitsize] sfz_sbh_rect:value] 191 | 192 | #define SFZ_SBH_EdgeInsets(value) \ 193 | [[SwiftyFitsize sharedSwiftyFitsize] sfz_sbh_EdgeInsets:value] 194 | 195 | #endif /* SwiftFitSizeOC_h */ 196 | -------------------------------------------------------------------------------- /SwiftyFitsize.podspec: -------------------------------------------------------------------------------- 1 | # 2 | 3 | Pod::Spec.new do |s| 4 | s.name = 'SwiftyFitsize' 5 | s.version = '1.4.2' 6 | s.summary = '📱 Swifty screen adaptation solution' 7 | s.homepage = 'https://github.com/LinXunFeng/SwiftyFitsize' 8 | s.license = { :type => 'MIT', :file => 'LICENSE' } 9 | s.author = { 'LinXunFeng' => '598600855@qq.com' } 10 | s.source = { :git => 'https://github.com/LinXunFeng/SwiftyFitsize.git', :tag => s.version.to_s } 11 | 12 | s.swift_version = '5.0' 13 | s.ios.deployment_target = '9.0' 14 | 15 | s.source_files = 'Sources/**/*.{h,swift}' 16 | s.public_header_files = 'Sources/**/*.h' 17 | 18 | end 19 | -------------------------------------------------------------------------------- /_Pods.xcodeproj: -------------------------------------------------------------------------------- 1 | Example/Pods/Pods.xcodeproj -------------------------------------------------------------------------------- /fastlane/Fastfile: -------------------------------------------------------------------------------- 1 | desc 'Usage help' 2 | lane :usage do |options| 3 | UI.message("input") 4 | UI.message("fastlane release version:{version_number}") 5 | UI.message("or") 6 | UI.message("fastlane release version:{version_number} message:{version_message}") 7 | end 8 | 9 | desc 'Release new version' 10 | lane :release do |options| 11 | 12 | target_version = options[:version] 13 | version_message = options[:message] 14 | raise "The version is missed. Use `fastlane release version:{version_number}`.`" if target_version.nil? 15 | 16 | version_bump_podspec( 17 | path: "SwiftyFitsize.podspec", 18 | version_number: target_version 19 | ) 20 | 21 | git_add(path: ".") 22 | git_commit(path: ".", message: "Bump version to #{target_version}") 23 | 24 | if git_tag_exists(tag: target_version) 25 | UI.message("remote the existing tag #{target_version} automatically") 26 | remove_git_tag(tagNum: target_version) 27 | end 28 | 29 | if version_message.nil? 30 | add_git_tag( 31 | tag: target_version 32 | ) 33 | else 34 | add_git_tag( 35 | tag: target_version, 36 | message: version_message 37 | ) 38 | end 39 | 40 | 41 | push_git_tags 42 | push_to_git_remote 43 | 44 | pod_lib_lint(allow_warnings: true) 45 | 46 | pod_push(allow_warnings: true) 47 | 48 | end -------------------------------------------------------------------------------- /fastlane/README.md: -------------------------------------------------------------------------------- 1 | fastlane documentation 2 | ---- 3 | 4 | # Installation 5 | 6 | Make sure you have the latest version of the Xcode command line tools installed: 7 | 8 | ```sh 9 | xcode-select --install 10 | ``` 11 | 12 | For _fastlane_ installation instructions, see [Installing _fastlane_](https://docs.fastlane.tools/#installing-fastlane) 13 | 14 | # Available Actions 15 | 16 | ### usage 17 | 18 | ```sh 19 | [bundle exec] fastlane usage 20 | ``` 21 | 22 | Usage help 23 | 24 | ### release 25 | 26 | ```sh 27 | [bundle exec] fastlane release 28 | ``` 29 | 30 | Release new version 31 | 32 | ---- 33 | 34 | This README.md is auto-generated and will be re-generated every time [_fastlane_](https://fastlane.tools) is run. 35 | 36 | More information about _fastlane_ can be found on [fastlane.tools](https://fastlane.tools). 37 | 38 | The documentation of _fastlane_ can be found on [docs.fastlane.tools](https://docs.fastlane.tools). 39 | -------------------------------------------------------------------------------- /fastlane/actions/remove_git_tag.rb: -------------------------------------------------------------------------------- 1 | module Fastlane 2 | module Actions 3 | module SharedValues 4 | REMOVE_GIT_TAG_CUSTOM_VALUE = :REMOVE_GIT_TAG_CUSTOM_VALUE 5 | end 6 | 7 | class RemoveGitTagAction < Action 8 | def self.run(params) 9 | 10 | # params[:参数名称] 参数名称与下面self.available_options中的保持一致 11 | tagNum = params[:tagNum] 12 | rmLocalTag = params[:rmLocalTag] 13 | rmRemoteTag = params[:rmRemoteTag] 14 | 15 | command = [] 16 | if rmLocalTag 17 | # 删除本地标签 18 | # git tag -d 标签名称 19 | command << "git tag -d #{tagNum}" 20 | end 21 | if rmRemoteTag 22 | # 删除远程标签 23 | # git push origin :标签名称 24 | command << "git push origin :#{tagNum}" 25 | end 26 | 27 | result = Actions.sh(command.join('&')) 28 | UI.success("Successfully remove tag 🚀 ") 29 | return result 30 | 31 | end 32 | 33 | ##################################################### 34 | # @!group Documentation 35 | ##################################################### 36 | 37 | # 可以使用 fastlane action remove_git_tag 来参看详细描述 38 | # 39 | 40 | def self.description 41 | "删除tag" 42 | end 43 | 44 | def self.details 45 | "使用当前action来删除本地和远程冲突的tag" 46 | end 47 | 48 | def self.available_options 49 | # Define all options your action supports. 50 | 51 | # Below a few examples 52 | [ 53 | FastlaneCore::ConfigItem.new(key: :tagNum, 54 | description: "输入即将删除的tag", 55 | is_string: true), 56 | FastlaneCore::ConfigItem.new(key: :rmLocalTag, 57 | description: "是否删除本地tag", 58 | optional:true, 59 | is_string: false, 60 | default_value: true), 61 | FastlaneCore::ConfigItem.new(key: :rmRemoteTag, 62 | description: "是否删除远程tag", 63 | optional:true, 64 | is_string: false, 65 | default_value: true) 66 | ] 67 | end 68 | 69 | def self.output 70 | # Define the shared values you are going to provide 71 | # Example 72 | # [ 73 | # ['REMOVE_GIT_TAG_CUSTOM_VALUE', 'A description of what this value contains'] 74 | # ] 75 | end 76 | 77 | def self.return_value 78 | # If your method provides a return value, you can describe here what it does 79 | end 80 | 81 | def self.authors 82 | # So no one will ever forget your contribution to fastlane :) You are awesome btw! 83 | ["LinXunFeng"] 84 | end 85 | 86 | def self.is_supported?(platform) 87 | # you can do things like 88 | # 89 | # true 90 | # 91 | # platform == :ios 92 | # 93 | # [:ios, :mac].include?(platform) 94 | # 95 | 96 | platform == :ios 97 | end 98 | end 99 | end 100 | end 101 | --------------------------------------------------------------------------------