Menu

ATNativeADView

Native ad view class, responsible for the rendering and interaction control of native ads. Provides video playback control, ad display management, click tracking, special effect animations (such as shake and slide), etc., and provides 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, set the 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 the array of views used to track 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;

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

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

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

/**
 * Set whether to play muted
 * @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 AdChoices view for self-rendering ads
 * Only supports Meta (Facebook) ads
 */
- (void)setAdChoicesViewColor:(UIColor *)color;

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

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

// Prepare using the 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 Number of animation repetitions, -1 for infinite loop
 * @param animationWidth Animation area width (excluding text, must not exceed the frame size)
 * @param animationHeight Animation area height (excluding text, must not exceed the frame size)
 */
- (UIView *)getNetworkSlideViewWithFrame:(CGRect)frame
                                 repeat:(int)repeat
                         animationWidth:(CGFloat)animationWidth
                        animationHeight:(CGFloat)animationHeight;

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

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

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

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