From 838b6c9f6c169e83ef7bb182068a80436b97b1f2 Mon Sep 17 00:00:00 2001 From: Tim Oliver Date: Tue, 7 Apr 2026 23:15:33 +0900 Subject: [PATCH] Add back in common aspect ratio presets --- .../TOCropViewControllerAspectRatioPreset.h | 24 +++++++++++++++++++ .../TOCropViewControllerAspectRatioPreset.m | 9 +++++++ 2 files changed, 33 insertions(+) diff --git a/Objective-C/TOCropViewController/Models/TOCropViewControllerAspectRatioPreset.h b/Objective-C/TOCropViewController/Models/TOCropViewControllerAspectRatioPreset.h index fd0b4f15..abf64442 100644 --- a/Objective-C/TOCropViewController/Models/TOCropViewControllerAspectRatioPreset.h +++ b/Objective-C/TOCropViewController/Models/TOCropViewControllerAspectRatioPreset.h @@ -30,6 +30,30 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, readonly) CGSize size; @property (nonatomic, readonly) NSString *title; +/// The original aspect ratio of the image (CGSizeZero) +@property (class, nonatomic, readonly) CGSize original; + +/// A square aspect ratio (1:1) +@property (class, nonatomic, readonly) CGSize square; + +/// A 3:2 aspect ratio +@property (class, nonatomic, readonly) CGSize ratio3x2; + +/// A 5:3 aspect ratio +@property (class, nonatomic, readonly) CGSize ratio5x3; + +/// A 4:3 aspect ratio +@property (class, nonatomic, readonly) CGSize ratio4x3; + +/// A 5:4 aspect ratio +@property (class, nonatomic, readonly) CGSize ratio5x4; + +/// A 7:5 aspect ratio +@property (class, nonatomic, readonly) CGSize ratio7x5; + +/// A 16:9 aspect ratio +@property (class, nonatomic, readonly) CGSize ratio16x9; + + (NSArray *)portraitPresets; + (NSArray *)landscapePresets; diff --git a/Objective-C/TOCropViewController/Models/TOCropViewControllerAspectRatioPreset.m b/Objective-C/TOCropViewController/Models/TOCropViewControllerAspectRatioPreset.m index a12c92de..09bd7898 100644 --- a/Objective-C/TOCropViewController/Models/TOCropViewControllerAspectRatioPreset.m +++ b/Objective-C/TOCropViewController/Models/TOCropViewControllerAspectRatioPreset.m @@ -37,6 +37,15 @@ @interface TOCropViewControllerAspectRatioPreset () @implementation TOCropViewControllerAspectRatioPreset ++ (CGSize)original { return CGSizeZero; } ++ (CGSize)square { return CGSizeMake(1.0f, 1.0f); } ++ (CGSize)ratio3x2 { return CGSizeMake(3.0f, 2.0f); } ++ (CGSize)ratio5x3 { return CGSizeMake(5.0f, 3.0f); } ++ (CGSize)ratio4x3 { return CGSizeMake(4.0f, 3.0f); } ++ (CGSize)ratio5x4 { return CGSizeMake(5.0f, 4.0f); } ++ (CGSize)ratio7x5 { return CGSizeMake(7.0f, 5.0f); } ++ (CGSize)ratio16x9 { return CGSizeMake(16.0f, 9.0f); } + - (instancetype)initWithSize:(CGSize)size title:(NSString *)title { self = [super init]; if (self) {