Menu

ATNativeADView

Native ad view class, responsible for native ad rendering and interaction control, providing video playback control, ad display management, click tracking, special effects animations (such as shake and slide), and self-rendering related support.

Copy
@interface ATNativeADView : UIView<ATNativeRendering>

/**
 * Initialize subviews
 * Subclasses must call [super initSubviews] to ensure the ad view works correctly
 * When this method is called, the ad view is not yet fully ready
 */
-(void)initSubviews;

/**
 * Create constraints for subviews
 * If using auto-layout, please set constraints in this method
 */
-(void)makeConstraintsForSubviews;

/**
 * Determine whether the currently displayed ad is a video ad
 */
-(BOOL)isVideoContents;

/**
 * Get the actual rendered ad view
 * Be sure to use this method to get the real ad view
 */
-(ATNativeADView*)embededAdView;

/**
 * Return an array of views used for tracking clicks
 */
-(NSArray<UIView*>*)clickableViews;

// Ad delegate
@property(nonatomic, weak) id<ATNativeADDelegate> delegate;

/**
 * The currently displayed native ad object (read-only)
 */
@property(nonatomic, readonly) ATNativeAd *nativeAd;

/**
 * Network platform ID of the native ad (read-only)
 */
@property(nonatomic, readonly) NSInteger networkFirmID;

/**
 * Get the video ad playback duration (milliseconds)
 */
- (CGFloat)videoPlayTime;

/**
 * Get the video ad total duration (milliseconds)
 */
- (CGFloat)videoDuration;

/**
 * Set whether to mute playback
 * @param flag Whether to mute
 */
- (void)muteEnable:(BOOL)flag;

/**
 * Play the video ad
 */
- (void)videoPlay;

/**
 * Pause the video ad
 */
- (void)videoPause;

/**
 * Destroy the network native ad
 */
- (void)destroyNative;

/**
 * Get the native ad type
 */
- (ATNativeAdType)getNativeAdType;

/**
 * Get the native ad rendering type
 */
- (ATNativeAdRenderType)getCurrentNativeAdRenderType;

/**
 * Set the background color of the self-rendering ad's AdChoices view
 * Only supports Meta (Facebook) ads
 */
- (void)setAdChoicesViewColor:(UIColor *)color;

// Self-rendering view
@property(nonatomic, strong) UIView *selfRenderView;

// Record custom player status
- (void)recordCustomPlayerStatus:(ATPlayerStatus)status currentTime:(NSTimeInterval)time;

// Prepare using native ad preparation info
- (void)prepareWithNativePrepareInfo:(ATNativePrepareInfo *)nativePrepareInfo;

// Get the media view
- (nullable UIView *)getMediaView;

// Get the native shake view
- (UIView *)getNetworkShakeViewWithFrame:(CGRect)frame;

/**
 * Initialize the slide component (only supports Baidu)
 * @param frame Component frame
 * @param repeat Animation repeat count, -1 for infinite loop
 * @param animationWidth Animation area width (excluding text, must not exceed frame size)
 * @param animationHeight Animation area height (excluding text, must not exceed frame size)
 */
- (UIView *)getNetworkSlideViewWithFrame:(CGRect)frame
                                 repeat:(int)repeat
                         animationWidth:(CGFloat)animationWidth
                        animationHeight:(CGFloat)animationHeight;

// Initialize using configuration, current ad offer, and Ad Placement ID
- (instancetype)initWithConfiguration:(ATNativeADConfiguration*)configuration 
                       currentOffer:(ATNativeAdOffer *)currentOffer 
                       placementID:(NSString*)placementID;

// Update the ad view configuration
- (void)updateAdViewConfiguration:(ATNativeADConfiguration*)configuration 
                    currentOffer:(ATNativeAdOffer *)currentOffer 
                    placementID:(NSString*)placementID;

// Register an array of clickable views
- (void)registerClickableViewArray:(NSArray *)registerClickViewArray;

@end
Previous
ATNativeAdOffer
Next
ATNativeBannerView
Last modified: 2026-07-08Powered by