You could just animate the alpha value of your AdBannerView
to achieve the effect you want:
import iAd
private var bannerView: AdBannerView!
override func viewDidLoad() {
super.viewDidLoad()
// Create your banner view however you want, and add it to your UI.
bannerView = AdBannerView()
bannerView.alpha = 0
addSubview(bannerView)
}
// When you want to show the ad, animate the alpha.
private func animateInAd(appearing: Bool) {
UIView.animateWithDuration(1.0) [weak self] {
self?.bannerView.alpha = appearing ? 1 : 0
}
}
Here is another way you can present bannerView. You can remove the view on top of the ad when it has finished sliding up:
import iAd
private var coverView: UIView!
private var bannerView: AdBannerView!
override func viewDidLoad() {
super.viewDidLoad()
// Create your banner view however you want, and add it to your UI.
bannerView = AdBannerView()
addSubview(bannerView)
// Create the cover view however you want, and add it above the banner view.
coverView = UIView()
addSubview(coverView)
}
private func animateInAd(appearing: Bool) {
let hideAdPosition = view.frame.size.height
let showAdPosition = hideAdPosition - bannerView.frame.size.height
UIView.animateWithDuration(1.0, animations: [weak self] {
self?.bannerView.frame.origin.y = appearing ? showAdPosition : hideAdPosition
}) { [weak self] success in
self?.animateCover(appearing: !appearing)
}
}
private func animateCover(appearing: Bool) {
UIView.animateWithDuration(1.0) [weak self] {
self?.coverView.alpha = appearing ? 1 : 0
}
}
EDIT:
As for ADInterstitialAd
s, those seem to inherit from NSObject
and have explicit methods you need to call in order to present them (presentInView:
and presentFromViewController:
). Therefore, there is no public API to control how these ads are presented (This is likely done on purpose so that Apple can guarantee that the ad is shown to the user).