Skip to content

Commit 838b6c9

Browse files
committed
Add back in common aspect ratio presets
1 parent f876c1f commit 838b6c9

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

Objective-C/TOCropViewController/Models/TOCropViewControllerAspectRatioPreset.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,30 @@ NS_ASSUME_NONNULL_BEGIN
3030
@property (nonatomic, readonly) CGSize size;
3131
@property (nonatomic, readonly) NSString *title;
3232

33+
/// The original aspect ratio of the image (CGSizeZero)
34+
@property (class, nonatomic, readonly) CGSize original;
35+
36+
/// A square aspect ratio (1:1)
37+
@property (class, nonatomic, readonly) CGSize square;
38+
39+
/// A 3:2 aspect ratio
40+
@property (class, nonatomic, readonly) CGSize ratio3x2;
41+
42+
/// A 5:3 aspect ratio
43+
@property (class, nonatomic, readonly) CGSize ratio5x3;
44+
45+
/// A 4:3 aspect ratio
46+
@property (class, nonatomic, readonly) CGSize ratio4x3;
47+
48+
/// A 5:4 aspect ratio
49+
@property (class, nonatomic, readonly) CGSize ratio5x4;
50+
51+
/// A 7:5 aspect ratio
52+
@property (class, nonatomic, readonly) CGSize ratio7x5;
53+
54+
/// A 16:9 aspect ratio
55+
@property (class, nonatomic, readonly) CGSize ratio16x9;
56+
3357
+ (NSArray<TOCropViewControllerAspectRatioPreset *> *)portraitPresets;
3458
+ (NSArray<TOCropViewControllerAspectRatioPreset *> *)landscapePresets;
3559

Objective-C/TOCropViewController/Models/TOCropViewControllerAspectRatioPreset.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ @interface TOCropViewControllerAspectRatioPreset ()
3737

3838
@implementation TOCropViewControllerAspectRatioPreset
3939

40+
+ (CGSize)original { return CGSizeZero; }
41+
+ (CGSize)square { return CGSizeMake(1.0f, 1.0f); }
42+
+ (CGSize)ratio3x2 { return CGSizeMake(3.0f, 2.0f); }
43+
+ (CGSize)ratio5x3 { return CGSizeMake(5.0f, 3.0f); }
44+
+ (CGSize)ratio4x3 { return CGSizeMake(4.0f, 3.0f); }
45+
+ (CGSize)ratio5x4 { return CGSizeMake(5.0f, 4.0f); }
46+
+ (CGSize)ratio7x5 { return CGSizeMake(7.0f, 5.0f); }
47+
+ (CGSize)ratio16x9 { return CGSizeMake(16.0f, 9.0f); }
48+
4049
- (instancetype)initWithSize:(CGSize)size title:(NSString *)title {
4150
self = [super init];
4251
if (self) {

0 commit comments

Comments
 (0)