GRVNavigationBackButtonItemProtocol
IAPMiniProgram SDK provides the ability to customize the style of the back button in the title bar of the mini program, so that the Super App can use its own text or image to customize and render the back button of the mini programs accordingly. Follow this topic to realize this customization ability by implementing the specific interface of IAPMiniProgram SDK.
Procedures
Step 1. Implement the GRVNavigationBackButtonItemProtocol protocol
Implement the GRVNavigationBackButtonItemProtocol protocol and write code in the required methods according to your business logic.
Code sample as follows:
Sample: Image button
class BackButtonCustomization: NSObject, GRVNavigationBackButtonItemProtocol {
var itemContentType: GRVNavigationItemContentType = .image
var image: UIImage? = UIImage(named: "xxx")?.withRenderingMode(.alwaysOriginal)
var text: String? = nil
}
Sample: Text button
class BackButtonCustomization: NSObject, GRVNavigationBackButtonItemProtocol {
var itemContentType: GRVNavigationItemContentType = .text
var image: UIImage? = nil
var text: String? = "xxx"
}
Step 2. Configure the GRVNavigationBackButtonItemProtocol protocol
Refer to the following sample code. Configure the GRVExtensionDelegate interface to register GRVNavigationBackButtonItemProtocol after initializing the SDK.
let extensionDelegate = GRVExtensionDelegate()
extensionDelegate.uiProvider.pageBackButtonItemSetting = BackButtonCustomization()
Then you can view the following screenshots for user experience.
Protocols
GRVNavigationBackButtonItemProtocol protocol
The definition of the GRVNavigationBackButtonItemProtocol protocol is shown in the following codes:
typedef NS_ENUM(NSUInteger, GRVNavigationItemContentType) {
GRVNavigationItemContentText,
GRVNavigationItemContentImage
};
@protocol GRVNavigationItemProtocol <NSObject>
@required
@property (nonatomic, assign) GRVNavigationItemContentType itemContentType;
@property (nonatomic, copy) NSString * _Nullable text;
@property (nonatomic, strong) UIImage * _Nullable image;
@end
@protocol GRVNavigationBackButtonItemProtocol <GRVNavigationItemProtocol>
@end
Parameter | Data type | Required | Description |
itemContentType | GRVNavigationItemContentType | Yes | Indicates the style of the back button that can be customized. Valid values:
|
text | String | No | Indicates the customized text for the back button. Note: When itemContentType = |
image | UIImage | No | Indicates the customized image for the back button. Note: When itemContentType = |
Appendices
User experience
Configuration | Screenshot |
When the back button style is customized image. | |
When the back button style is customized text. |