AUImageDialog is a dialog box with images. The dialog box has rounded corners, and the style can be customized. The window level of AUImageDialog is: self.windowLevel = UIWindowLevelAlert - 1
.
API description
// The index corresponding to button clicking.
typedef NS_ENUM(NSInteger, AUImageDialogButtonIndex) {
AUImageDialogButtonIndex_Close = -2,
AUImageDialogButtonIndex_Link = -1,
AUImageDialogButtonIndex_Action = 0
};
/**
The image dialog box is a special-style dialog box meeting the UED requirements, the shape of the images is round.
Two modes are available:
Common image mode: The Add button is a common button.
Action button mode: An action button and a link button can be added. A cross icon (X) is displayed in the upper right corner for users to exit.
The buttons in one mode cannot be added in the other mode. Otherwise, the adding cannot pass the assert check.
*/
@interface AUImageDialog : AUDialogBaseView
/**
The method of dialog box initialization without the button title.
@param image The image.
@param title The title.
@param message The message details.
@param delegate The AUDialogDelegate-compliant protocol object.
@return The AUImageDialog instance.
*/
- (instancetype)initWithImage:(UIImage *)image
title:(NSString *)title
message:(NSString *)message
delegate:(id<AUDialogDelegate>)delegate;
/**
The method of dialog box initialization with the button title.
@param image The image.
@param title The title.
@param message The message details.
@param delegate The AUDialogDelegate-compliant protocol object.
@param buttonTitle The list of button title parameters.
@return The AUImageDialog instance.
*/
- (instancetype)initWithImage:(UIImage *)image
title:(NSString *)title
message:(NSString *)message
delegate:(id<AUDialogDelegate>)delegate
buttonTitles:(NSString *)buttonTitle, ... NS_REQUIRES_NIL_TERMINATION;
/**
The initialization method with a blue action button.
@param image The image.
@param title The title.
@param message The message details.
@param delegate The AUDialogDelegate-compliant protocol object.
@param actionTitle The title of the action button.
@return The AUImageDialog instance.
*/
- (instancetype)initWithImage:(UIImage *)image
title:(NSString *)title
message:(NSString *)message
delegate:(id<AUDialogDelegate>)delegate
actionButtonTitle:(NSString *)actionTitle;
/**
The initialization method with a blue action button and a link button.
@param image The image.
@param title The title.
@param message The message details.
@param delegate The AUDialogDelegate-compliant protocol object.
@param linkText The link text.
@param actionTitle The title of the action button.
@return The AUImageDialog instance.
*/
- (instancetype)initWithImage:(UIImage *)image
title:(NSString *)title
message:(NSString *)message
delegate:(id<AUDialogDelegate>)delegate
linkText:(NSString *)linkText
actionButtonTitle:(NSString *)actionTitle;
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithCustomView:(UIView *)customView; // The custom view, with the X button in the upper right corner by default.
/**
The dialog box display method.
*/
- (void)show;
/**
Set the text color to gray. Default value: NO.
*/
- (void)setGrayMessage:(BOOL)grayMessage;
/**
Set the text alignment mode.
@param alignment The alignment mode.
*/
- (void)setMessageAlignment:(NSTextAlignment)alignment;
/**
Set the custom image size. The width cannot exceed the dialog box's maximum width of 270. Default value: 135 x 135.
*/
- (void)configImageAreaSize:(CGSize)imageSize;
/**
Add a common button and its callback method (The common button cannot contain an action or a link).
@param buttonTitle The common button title.
@param actionBlock The callback of the button.
*/
- (void)addButton:(NSString *)buttonTitle actionBlock:(AUDialogActionBlock)actionBlock;
/**
Add an action button and its callback method.
@param actionTitle The title of the action button.
@param actionBlock The callback of the action button.
*/
- (void)addActionButton:(NSString *)actionTitle actionBlock:(AUDialogActionBlock)actionBlock;
/**
Add a link button and its callback method.
@param linkText The link text.
@param actionBlock The callback of the link button.
*/
- (void)addLinkButton:(NSString *)linkText actionBlock:(AUDialogActionBlock)actionBlock;
/**
Hide the close button in the upper right corner.
*/
- (void)setCloseButtonHidden:(BOOL) hidden;
API for a large image style AUImageDialog
/**
The image dialog box has a special UED-required style.
* Style: The large icon style. In this style, the image has a fixed height of 312 px, and the close button is in the upper right corner of the image.
* The icon font of the close button. Default value: white.
*/
@interface AUImageDialog (largeImageStyle)
/**
The method of dialog box initialization without the button title.
@param image The image.
@param title The title.
@param message The message details.
@param delegate The AUDialogDelegate-compliant protocol object.
@return The AUImageDialog instance.
*/
- (instancetype)initWithLargeImage:(UIImage *)image
title:(NSString *)title
message:(NSString *)message
delegate:(id<AUDialogDelegate>)delegate;
/**
* Set the color of the close button in the upper right corner. Default value: white.
*/
- (void)resetCloseIconColor:(UIColor *)color;
@end
Sample code
With common buttons
UIImage *image = [UIImage imageNamed:@"panghu.jpg"]; AUImageDialog *dialog = [[AUImageDialog alloc] initWithImage:image title:@"Goda Takeshi" message:@"Strict match. The one not in the delegate is not a standard control. The one not in the delegate but has been used in many places should be delivered in the candidate control set. A delegate, such as the title delegate, may not be implemented as a single control." delegate:self]; [dialog addButton:@"Cancel" actionBlock:nil]; [dialog addButton:@"OK" actionBlock:nil]; [dialog show];
Custom style
UIView *customView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 240, 60)]; customView.backgroundColor = [UIColor greenColor]; AUImageDialog *dialog = [[AUImageDialog alloc] initWithCustomView:customView]; [dialog addButton:@"Cancel" actionBlock:nil]; [dialog addButton:@"OK" actionBlock:nil]; [dialog show];
With a large image
UIImage *image = [UIImage imageWithColor:[UIColor colorWithRGB:0xD8D8D8] size:CGSizeMake(100, 100)]; AUImageDialog *dialog = [[AUImageDialog alloc] initWithLargeImage:image title:@"Title in a line" message:@"Illustrate the status and prompt a solution. No more than two lines." delegate:self]; [dialog addButton:@"Cancel" actionBlock:nil]; [dialog addButton:@"OK" actionBlock:nil]; [dialog resetCloseIconColor:[UIColor redColor]]; [dialog show];