All Products
Search
Document Center

Image dialog

Last Updated: May 25, 2021

AUImageDialog is a dialog box with images. The dialog box has rounded corners, and the style can be customized, as shown in the following sample images. The window level of AUImageDialog is: self.windowLevel = UIWindowLevelAlert - 1.

Sample images

  • With common buttons

  • Custom style

  • With a large image

API description

 
  1. // The index corresponding to button clicking.
  2. typedef NS_ENUM(NSInteger, AUImageDialogButtonIndex) {
  3. AUImageDialogButtonIndex_Close = -2,
  4. AUImageDialogButtonIndex_Link = -1,
  5. AUImageDialogButtonIndex_Action = 0
  6. };
  7. /**
  8. The image dialog box is a special-style dialog box meeting the UED requirements, the shape of the images is round.
  9. Two modes are available:
  10. Common image mode: The Add button is a common button.
  11. 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.
  12. The buttons in one mode cannot be added in the other mode. Otherwise, the adding cannot pass the assert check.
  13. */
  14. @interface AUImageDialog : AUDialogBaseView
  15. /**
  16. The method of dialog box initialization without the button title.
  17. @param image The image.
  18. @param title The title.
  19. @param message The message details.
  20. @param delegate The AUDialogDelegate-compliant protocol object.
  21. @return The AUImageDialog instance.
  22. */
  23. - (instancetype)initWithImage:(UIImage *)image
  24. title:(NSString *)title
  25. message:(NSString *)message
  26. delegate:(id<AUDialogDelegate>)delegate;
  27. /**
  28. The method of dialog box initialization with the button title.
  29. @param image The image.
  30. @param title The title.
  31. @param message The message details.
  32. @param delegate The AUDialogDelegate-compliant protocol object.
  33. @param buttonTitle The list of button title parameters.
  34. @return The AUImageDialog instance.
  35. */
  36. - (instancetype)initWithImage:(UIImage *)image
  37. title:(NSString *)title
  38. message:(NSString *)message
  39. delegate:(id<AUDialogDelegate>)delegate
  40. buttonTitles:(NSString *)buttonTitle, ... NS_REQUIRES_NIL_TERMINATION;
  41. /**
  42. The initialization method with a blue action button.
  43. @param image The image.
  44. @param title The title.
  45. @param message The message details.
  46. @param delegate The AUDialogDelegate-compliant protocol object.
  47. @param actionTitle The title of the action button.
  48. @return The AUImageDialog instance.
  49. */
  50. - (instancetype)initWithImage:(UIImage *)image
  51. title:(NSString *)title
  52. message:(NSString *)message
  53. delegate:(id<AUDialogDelegate>)delegate
  54. actionButtonTitle:(NSString *)actionTitle;
  55. /**
  56. The initialization method with a blue action button and a link button.
  57. @param image The image.
  58. @param title The title.
  59. @param message The message details.
  60. @param delegate The AUDialogDelegate-compliant protocol object.
  61. @param linkText The link text.
  62. @param actionTitle The title of the action button.
  63. @return The AUImageDialog instance.
  64. */
  65. - (instancetype)initWithImage:(UIImage *)image
  66. title:(NSString *)title
  67. message:(NSString *)message
  68. delegate:(id<AUDialogDelegate>)delegate
  69. linkText:(NSString *)linkText
  70. actionButtonTitle:(NSString *)actionTitle;
  71. - (instancetype)init NS_UNAVAILABLE;
  72. - (instancetype)initWithCustomView:(UIView *)customView; // The custom view, with the X button in the upper right corner by default.
  73. /**
  74. The dialog box display method.
  75. */
  76. - (void)show;
  77. /**
  78. Set the text color to gray. Default value: NO.
  79. */
  80. - (void)setGrayMessage:(BOOL)grayMessage;
  81. /**
  82. Set the text alignment mode.
  83. @param alignment The alignment mode.
  84. */
  85. - (void)setMessageAlignment:(NSTextAlignment)alignment;
  86. /**
  87. Set the custom image size. The width cannot exceed the dialog box's maximum width of 270. Default value: 135 x 135.
  88. */
  89. - (void)configImageAreaSize:(CGSize)imageSize;
  90. /**
  91. Add a common button and its callback method (The common button cannot contain an action or a link).
  92. @param buttonTitle The common button title.
  93. @param actionBlock The callback of the button.
  94. */
  95. - (void)addButton:(NSString *)buttonTitle actionBlock:(AUDialogActionBlock)actionBlock;
  96. /**
  97. Add an action button and its callback method.
  98. @param actionTitle The title of the action button.
  99. @param actionBlock The callback of the action button.
  100. */
  101. - (void)addActionButton:(NSString *)actionTitle actionBlock:(AUDialogActionBlock)actionBlock;
  102. /**
  103. Add a link button and its callback method.
  104. @param linkText The link text.
  105. @param actionBlock The callback of the link button.
  106. */
  107. - (void)addLinkButton:(NSString *)linkText actionBlock:(AUDialogActionBlock)actionBlock;
  108. /**
  109. Hide the close button in the upper right corner.
  110. */
  111. - (void)setCloseButtonHidden:(BOOL) hidden;

API for a large image style AUImageDialog

 
  1. /**
  2. The image dialog box has a special UED-required style.
  3. * 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.
  4. * The icon font of the close button. Default value: white.
  5. */
  6. @interface AUImageDialog (largeImageStyle)
  7. /**
  8. The method of dialog box initialization without the button title.
  9. @param image The image.
  10. @param title The title.
  11. @param message The message details.
  12. @param delegate The AUDialogDelegate-compliant protocol object.
  13. @return The AUImageDialog instance.
  14. */
  15. - (instancetype)initWithLargeImage:(UIImage *)image
  16. title:(NSString *)title
  17. message:(NSString *)message
  18. delegate:(id<AUDialogDelegate>)delegate;
  19. /**
  20. * Set the color of the close button in the upper right corner. Default value: white.
  21. */
  22. - (void)resetCloseIconColor:(UIColor *)color;
  23. @end

Sample code

  • With common buttons

       
    1. UIImage *image = [UIImage imageNamed:@"panghu.jpg"];
    2. 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];
    3. [dialog addButton:@"Cancel" actionBlock:nil];
    4. [dialog addButton:@"OK" actionBlock:nil];
    5. [dialog show];
  • Custom style

       
    1. UIView *customView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 240, 60)];
    2. customView.backgroundColor = [UIColor greenColor];
    3. AUImageDialog *dialog = [[AUImageDialog alloc] initWithCustomView:customView];
    4. [dialog addButton:@"Cancel" actionBlock:nil];
    5. [dialog addButton:@"OK" actionBlock:nil];
    6. [dialog show];
  • With a large image

       
    1. UIImage *image = [UIImage imageWithColor:[UIColor colorWithRGB:0xD8D8D8] size:CGSizeMake(100, 100)];
    2. 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];
    3. [dialog addButton:@"Cancel" actionBlock:nil];
    4. [dialog addButton:@"OK" actionBlock:nil];
    5. [dialog resetCloseIconColor:[UIColor redColor]];
    6. [dialog show];