All Products
Search
Document Center

Button base class

Last Updated: May 14, 2021

AUButton follows the new UED requirements, currently contains two styles, and cannot be fully interconnected with APButton in APCommonUI. These two styles do not include the operation button of the warning type in the sample image.

Sample images

button

Dependency

The dependency of AUButton is as follows:

 
  1. import <UIKit/UIKit.h>

API description

 
  1. /**
  2. Initialization method
  3. @param style The style.
  4. @return The created initialization object.
  5. */
  6. + (instancetype)buttonWithStyle:(AUButtonStyle)style;
  7. /**
  8. * An auxiliary method of the initialization, used for creating and initializing a button object.
  9. *
  10. * @param buttonType The button type. It must be one of the values defined in AUButtonStyle.
  11. * @param title Button title.
  12. * @param target The object responding to the button tap event.
  13. * @param action The function responding to the button tap event.
  14. *
  15. * @return The button object newly created and initialized.
  16. *
  17. * The initialization object of this method. A frame needs to be set.
  18. */
  19. + (instancetype)buttonWithStyle:(AUButtonStyle)style title:(NSString *)title target:(id)target action:(SEL)action;
  20. /**
  21. Display the loading icon animation and text (the loading icon is on the left and the text is on the right). When there is no text, the loading icon is centered.
  22. @param loadingTitle The text to be displayed along with the loading icon. If this parameter is set to nil or an empty string, text is not displayed and the loading icon is centered.
  23. @param currentVC The current VC that is used to remove the mask after the loading is complete.
  24. */
  25. - (void)startLoadingWithTitle:(NSString *)loadingTitle currentViewController:(UIViewController *)currentVC;
  26. /**
  27. Stop the rotation of the loading icon.
  28. */
  29. - (void)stopLoading;

Custom properties

Property Description
AUButtonStyleNone The default style.
AUButtonStyle1 Blue background, white text, borderless, and large button.
AUButtonStyle2 White background, black text, light gray border, and large button.
AUButtonStyle3 Transparent background, blue text, blue border, and small button.
AUButtonStyle4 White background, with upper and lower separation lines by default, and red text; applicable to page bottom operation scenarios (unfollow); default height: 44 units; width: same as screen width.
AUButtonStyle5 White background, with upper and lower separation lines by default, and ant blue text; applicable to page bottom operation scenarios (more services); default height: 44 units, and width: same as screen width
AUButtonStyle6 Red background, white text, for operations of the warning type, and large button.
AUButtonStyle7 White background, black text, light gray border, and small button.
AUButtonStyle8 Blue background, white text, borderless, and small button.

Code sample

 
  1. AUButton *button = [AUButton buttonWithStyle:AUButtonStyle2 title:@"AUButtonStyle2" target:self action:@selector(onButtonClicked:)];
  2. button.frame = CGRectMake(XX, XX,XX, XX);
  3. AUButton *buttonDisable = [AUButton buttonWithStyle:AUButtonStyle1];
  4. buttonDisable.enabled = NO;
  5. [buttonDisable setTitle:@"Style1disable" forState:UIControlStateNormal];
  6. buttonDisable.frame = CGRectMake(XX, XX,XX, XX);
  7. //Set the loading icon on the button.
  8. [button startLoadingWithTitle:@"Loading" currentViewController:self];
  9. //Stop the rotation of the loading icon on the button.
  10. [button stopLoading];