https://github.com/ysoftware/banner-view-controller
(Swift) Puts adaptive ad banner on your screen with a few lines of code
https://github.com/ysoftware/banner-view-controller
Last synced: 3 months ago
JSON representation
(Swift) Puts adaptive ad banner on your screen with a few lines of code
- Host: GitHub
- URL: https://github.com/ysoftware/banner-view-controller
- Owner: ysoftware
- Created: 2015-07-03T09:40:49.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-10-11T12:26:51.000Z (over 9 years ago)
- Last Synced: 2025-01-19T23:29:23.941Z (about 1 year ago)
- Language: Swift
- Homepage:
- Size: 20.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Banner View Controller
A port of Apple's BannerViewController to Swift. Requires target of iOS 8.1 or higher.
There is also a pure adMob version.
Works great with both iPad and iPhone.
####Installation
Add files to your project. Don't forget to set the target.
####How to use
This class wraps around your rootViewController, shows the banner and resizes rootViewController with animation. Check AppDelegate.swift for live usage example.
######iAd
```swift
let bannerVC = BannerViewController(contentController: window.rootViewController)
window.rootViewController = bannerVC
```
######AdMob:
```swift
let bannerVC = GoogleBannerViewController(contentController: window?.rootViewController, adUnitId: "your_ad_unit_id")
window.rootViewController = bannerVC
```
####Controlling the banner
You can turn on/off the banner when needed.
```swift
bannerVC.enabled(false) // Removes ad banner from the view hierarchy
```
Also when ADBannerView state changes these notifications are posted:
```swift
BannerViewActionWillBegin // User clicked on banner
BannerViewActionDidFinish // User dismissed the full screen experience
BannerViewDidFailToReceiveAdWithError // Banner didn't load. Get description from userinfo["error"] (String)
BannerViewDidLoadAd // Ad banner successfully loaded
```
Watch "Optimize Your Earning Power With iAd" from WWDC 2014 to for more details.