FWImageCropController
@interface FWImageCropController : UIViewController
FWImageCropController
-
The original, uncropped image that was passed to this controller.
Declaration
Objective-C
@property (nonatomic, readonly, nonnull) UIImage *image;
-
The minimum croping aspect ratio. If set, user is prevented from setting cropping rectangle to lower aspect ratio than defined by the parameter.
Declaration
Objective-C
@property (nonatomic) CGFloat minimumAspectRatio;
-
The view controller’s delegate that will receive the resulting cropped image, as well as crop information.
Declaration
Objective-C
@property (nonatomic, weak, nullable) id<FWImageCropControllerDelegate> delegate;
-
The crop view managed by this view controller.
Declaration
Objective-C
@property (nonatomic, strong, readonly, nonnull) FWImageCropView *cropView;
-
In the coordinate space of the image itself, the region that is currently being highlighted by the crop box.
This property can be set before the controller is presented to have the image ‘restored’ to a previous cropping layout.
Declaration
Objective-C
@property (nonatomic) CGRect imageCropFrame;
-
The angle in which the image is rotated in the crop view. This can only be in 90 degree increments (eg, 0, 90, 180, 270).
This property can be set before the controller is presented to have the image ‘restored’ to a previous cropping layout.
Declaration
Objective-C
@property (nonatomic) NSInteger angle;
-
The toolbar view managed by this view controller.
Declaration
Objective-C
@property (nonatomic, strong, readonly, nonnull) FWImageCropToolbar *toolbar;
-
自定义工具栏高度,默认同系统
Declaration
Objective-C
@property (nonatomic) CGFloat toolbarHeight;
-
The cropping style of this particular crop view controller
Declaration
Objective-C
@property (nonatomic, readonly) FWImageCropCroppingStyle croppingStyle;
-
A choice from one of the pre-defined aspect ratio presets
Declaration
Objective-C
@property (nonatomic) FWImageCropAspectRatioPreset aspectRatioPreset;
-
A CGSize value representing a custom aspect ratio, not listed in the presets. E.g. A ratio of 4:3 would be represented as (CGSize){4.0f, 3.0f}
Declaration
Objective-C
@property (nonatomic) CGSize customAspectRatio;
-
If this is set alongside
customAspectRatio
, the custom aspect ratio will be shown as a selectable choice in the list of aspect ratios. (Default isnil
)Declaration
Objective-C
@property (nonatomic, copy, nullable) NSString *customAspectRatioName;
-
The original aspect ratio will be shown as first choice in the list of aspect ratios. (Default is
nil
)Declaration
Objective-C
@property (nonatomic, copy, nullable) NSString *originalAspectRatioName;
-
Title label which can be used to show instruction on the top of the crop view controller
Declaration
Objective-C
@property (nonatomic, readonly, nullable) UILabel *titleLabel;
-
自定义标题顶部间距,默认14
Declaration
Objective-C
@property (nonatomic) CGFloat titleTopPadding;
-
Title for the ‘Done’ button. Setting this will override the Default which is a localized string for “Done”.
Declaration
Objective-C
@property (nonatomic, copy, nullable) NSString *doneButtonTitle;
-
Title for the ‘Cancel’ button. Setting this will override the Default which is a localized string for “Cancel”.
Declaration
Objective-C
@property (nonatomic, copy, nullable) NSString *cancelButtonTitle;
-
If true, a custom aspect ratio is set, and the aspectRatioLockEnabled is set to YES, the crop box will swap it’s dimensions depending on portrait or landscape sized images. This value also controls whether the dimensions can swap when the image is rotated.
Default is NO.
Declaration
Objective-C
@property (nonatomic) BOOL aspectRatioLockDimensionSwapEnabled;
-
If true, while it can still be resized, the crop box will be locked to its current aspect ratio.
If this is set to YES, and
resetAspectRatioEnabled
is set to NO, then the aspect ratio button will automatically be hidden from the toolbar.Default is NO.
Declaration
Objective-C
@property (nonatomic) BOOL aspectRatioLockEnabled;
-
If true, tapping the reset button will also reset the aspect ratio back to the image default ratio. Otherwise, the reset will just zoom out to the current aspect ratio.
If this is set to NO, and
aspectRatioLockEnabled
is set to YES, then the aspect ratio button will automatically be hidden from the toolbar.Default is YES
Declaration
Objective-C
@property (nonatomic) BOOL resetAspectRatioEnabled;
-
The position of the Toolbar the default value is
FWImageCropToolbarPositionBottom
.Declaration
Objective-C
@property (nonatomic) FWImageCropToolbarPosition toolbarPosition;
-
When disabled, an additional rotation button that rotates the canvas in 90-degree segments in a clockwise direction is shown in the toolbar.
Default is NO.
Declaration
Objective-C
@property (nonatomic) BOOL rotateClockwiseButtonHidden;
-
Undocumented
Declaration
Objective-C
@property (nonatomic) BOOL hidesNavigationBar
-
When enabled, hides the rotation button, as well as the alternative rotation button visible when
showClockwiseRotationButton
is set to YES.Default is NO.
Declaration
Objective-C
@property (nonatomic) BOOL rotateButtonsHidden;
-
When enabled, hides the ‘Reset’ button on the toolbar.
Default is NO.
Declaration
Objective-C
@property (nonatomic) BOOL resetButtonHidden;
-
When enabled, hides the ‘Aspect Ratio Picker’ button on the toolbar.
Default is NO.
Declaration
Objective-C
@property (nonatomic) BOOL aspectRatioPickerButtonHidden;
-
When enabled, hides the ‘Done’ button on the toolbar.
Default is NO.
Declaration
Objective-C
@property (nonatomic) BOOL doneButtonHidden;
-
When enabled, hides the ‘Cancel’ button on the toolbar.
Default is NO.
Declaration
Objective-C
@property (nonatomic) BOOL cancelButtonHidden;
-
An array of
FWImageCropAspectRatioPreset
enum values denoting which aspect ratios the crop view controller may display (Default is nil. All are shown)Declaration
Objective-C
@property (nonatomic, strong, nullable) NSArray<NSNumber *> *allowedAspectRatios;
-
When the user hits cancel, or completes a UIActivityViewController operation, this block will be called, giving you a chance to manually dismiss the view controller
Declaration
Objective-C
@property (nonatomic, strong, nullable) void (^)(BOOL) onDidFinishCancelled;
-
Called when the user has committed the crop action, and provides just the cropping rectangle.
Declaration
Objective-C
@property (nonatomic, strong, nullable) void (^)(CGRect, NSInteger) onDidCropImageToRect;
Parameters
cropRect
A rectangle indicating the crop region of the image the user chose (In the original image’s local co-ordinate space)
angle
The angle of the image when it was cropped
-
Called when the user has committed the crop action, and provides both the cropped image with crop co-ordinates.
Declaration
Objective-C
@property (nonatomic, strong, nullable) void (^) (UIImage *_Nonnull __strong, CGRect, NSInteger) onDidCropToRect;
Parameters
image
The newly cropped image.
cropRect
A rectangle indicating the crop region of the image the user chose (In the original image’s local co-ordinate space)
angle
The angle of the image when it was cropped
-
If the cropping style is set to circular, this block will return a circle-cropped version of the selected image, as well as it’s cropping co-ordinates
Declaration
Objective-C
@property (nonatomic, strong, nullable) void (^) (UIImage *_Nonnull __strong, CGRect, NSInteger) onDidCropToCircleImage;
Parameters
image
The newly cropped image, clipped to a circle shape
cropRect
A rectangle indicating the crop region of the image the user chose (In the original image’s local co-ordinate space)
angle
The angle of the image when it was cropped
-
Creates a new instance of a crop view controller with the supplied image
Declaration
Objective-C
- (nonnull instancetype)initWithImage:(nonnull UIImage *)image;
Parameters
image
The image that will be used to crop.
-
Creates a new instance of a crop view controller with the supplied image and cropping style
Declaration
Objective-C
- (nonnull instancetype)initWithCroppingStyle:(FWImageCropCroppingStyle)style image:(nonnull UIImage *)image;
Parameters
style
The cropping style that will be used with this view controller (eg, rectangular, or circular)
image
The image that will be cropped
-
Resets object of FWImageCropController class as if user pressed reset button in the bottom bar themself
Declaration
Objective-C
- (void)resetCropViewLayout;
-
Set the aspect ratio to be one of the available preset options. These presets have specific behaviour such as swapping their dimensions depending on portrait or landscape sized images.
Declaration
Objective-C
- (void)setAspectRatioPreset:(FWImageCropAspectRatioPreset)aspectRatioPreset animated:(BOOL)animated;
Parameters
aspectRatioPreset
The aspect ratio preset
animated
Whether the transition to the aspect ratio is animated