Introduction
The XHLaunchAd is an easy-to-use and customizable ad framework for iOS apps. It allows you to show launch ads, such as images or videos, during app launch. This framework provides various options and configurations to create a visually appealing and engaging launch experience for your users.
Key Features
- Display static images or videos as launch ads
- Customize ad display duration, skip button, and countdown label
- Support ad caching for improved performance
- Handle ad events such as ad click, ad display completed, etc.
- Compatible with both Objective-C and Swift
Installation
To install XHLaunchAd, follow these steps:
- Open your project in Xcode
- Add the XHLaunchAd framework to your project
- Import the framework in your project file:
“`swift
import XHLaunchAd
“`
Usage
To display a launch ad using XHLaunchAd:
- Create an instance of XHLaunchAd and configure the ad options:
“`swift
let adConfig = XHLaunchImageAdConfiguration()
adConfig.imageNameOrURLString = “https://example.com/launch_image.png”
XHLaunchAd.show(with: adConfig)
“`
- Handle various ad events by implementing the XHLaunchAdDelegate protocol:
“`swift
extension ViewController: XHLaunchAdDelegate {
func xhLaunchAdClick() {
// Called when the launch ad is clicked
}
func xhLaunchAdShowFinish() {
// Called when the launch ad display is completed
}
// Implement other delegate methods as needed
}
“`
- Set the delegate for XHLaunchAd:
“`swift
XHLaunchAd.setLaunchAdDelegate(delegate: self)
“`
Customization
XHLaunchAd provides various customization options to enhance your launch ads:
- Customize the skip button appearance:
“`swift
let skipButtonConfig = XHLaunchAdButtonSkipConfiguration()
skipButtonConfig.skipBtnTitle = “Skip”
skipButtonConfig.skipBtnTitleFont = UIFont.systemFont(ofSize: 15)
skipButtonConfig.skipBtnTitleColor = UIColor.white
skipButtonConfig.skipBtnBackgroundColor = UIColor.gray
skipButtonConfig.skipBtnWidth = 60
skipButtonConfig.skipBtnHeight = 30
skipButtonConfig.skipBtnCornerRadius = 5
XHLaunchAd.skipButtonConfig = skipButtonConfig
“`
- Customize the countdown label appearance:
“`swift
let countdownLabelConfig = XHLaunchAdCustomization()
countdownLabelConfig.countDownTitleFont = UIFont.systemFont(ofSize: 12)
countdownLabelConfig.countDownTitleColor = UIColor.white
countdownLabelConfig.countDownBackgroundColor = UIColor.black.withAlphaComponent(0.3)
countdownLabelConfig.countDownCornerRadius = 15
XHLaunchAd.countdownLabelConfig = countdownLabelConfig
“`
Troubleshooting
If you encounter any issues or errors while using XHLaunchAd, consider the following troubleshooting steps:
- Make sure you have correctly integrated the XHLaunchAd framework into your project
- Check if the ad image or video URL is valid and accessible
- Ensure proper implementation of the XHLaunchAdDelegate methods
- Refer to the documentation or GitHub repository for additional guidance and support
Conclusion
The XHLaunchAd framework offers a seamless and customizable solution for displaying launch ads in your iOS app. By leveraging its features and options, you can enhance user engagement and provide an appealing first impression of your app.