Skip to content

Commit

Permalink
fixing an overlay to display on the top
Browse files Browse the repository at this point in the history
  • Loading branch information
matejdr committed Feb 17, 2020
1 parent 09f7f39 commit 3bade77
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions ios/RNAdManageNativeView.m
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,19 @@ - (void)adLoader:(GADAdLoader *)adLoader didReceiveUnifiedNativeAd:(GADUnifiedNa

GADUnifiedNativeAdView *nativeAdView = [[GADUnifiedNativeAdView alloc] init];
self.nativeAdView = nativeAdView;

if (self.frame.size.width <= 0 || self.frame.size.height <= 0) {
CGFloat width = self.frame.size.width;
if (width <= 0) {
width = 32;
}
CGFloat height = self.frame.size.height;
if (height <= 0) {
height = 32;
}
[self setFrame:CGRectMake(self.frame.origin.x, self.frame.origin.y, width, height)];
}
self.nativeAdView.frame = self.bounds;
self.nativeAdView.translatesAutoresizingMaskIntoConstraints = NO;
self.nativeAdView.contentMode = UIViewContentModeScaleAspectFit;
self.nativeAdView.clipsToBounds = YES;
Expand Down Expand Up @@ -505,6 +518,15 @@ - (void)registerViewsForInteraction:(NSArray<UIView *> *)clickableViews {
[self.nativeAdView addSubview:view];
self.nativeAdView.callToActionView = view;
}];
// a HACK to get the overlay to display on the top
for (UIView *subview in self.nativeAdView.subviews)
{
if (subview.frame.origin.x < 0) {
[subview setFrame:CGRectMake(0, subview.frame.origin.y, subview.frame.size.width, subview.frame.size.height)];
[subview removeFromSuperview];
[self.nativeAdView addSubview:subview];
}
}
}
}

Expand Down

0 comments on commit 3bade77

Please sign in to comment.