* [ActivityIndicator] Swift first in README * [AnimationTiming] Swift first in readme. * [AppBar] Swift first in readme. * [ButtonBar] Swift first in readme. * [Buttons] Swift first in readme. * [CollectionLayoutAttributes] Swift first in readme * [Collections] Swift first in readme. * [Dialogs] Swift first in readme. * [FeatureHighlight] Swift first in readme. * [FlexibleHeader] Swift first in readme. * [FontDiskLoader] Swift first in readme. * [HeaderStackView] Swift first in readme. * [Ink] Swift first in readme. * [NavigationBar] Swift first in readme. * [OverlayWindow] Adding missing site comments. Swift first in readme. * [PageControl] Swift first in readme. * [Palettes] Swift first in readme. * [ProgressView] Swift first in readme. * [RobotoFontLoader] Swift first in readme. * [ShadowElevations] Swift first in readme. * [ShadowLayer] Swift first in readme. * [Slider] Swift first in readme. * [Snackbar] Swift first in readme. * [SpritedAnimationView] Swift first in readme. * [Switch] Swift first in readme. * [Typography] Swift first in readme. * [ShadowLayer] Reducing font size in readme. * [Switch] Reducing font size in readme.
Overlay Window
Provides a window which can have an arbitrary number of overlay views that will sit above the root view of the window. Overlays will be the full size of the screen, and will be rotated as appropriate based on device orientation. For performance, owners of overlay views should set the |hidden| property to YES when the overlay is not in use.
Overlay Window is used by components such as Snackbar. Snackbar uses Overlay Window to ensure displayed message views are always visible to the user by being at the top of the view hierarchy.
Installation
Requirements
- Xcode 7.0 or higher.
- iOS SDK version 7.0 or higher.
Installation with CocoaPods
To add this component to your Xcode project using CocoaPods, add the following to your Podfile:
pod 'MaterialComponents/OverlayWindow'
Then, run the following command:
pod install
Usage
Importing
Before using the Overlay Window, you'll need to import it:
Swift
import MaterialComponents
Objective-C
#import "MaterialOverlayWindow.h"
Examples
Setting the Overlay Window
Using the Overlay Window requires that the App Delegate set the window as an Overlay Window or a subclass of Overlay Window.
Swift
func application(application: UIApplication, didFinishLaunchingWithOptions
launchOptions: [NSObject: AnyObject]?) -> Bool {
...
self.window = MDCOverlayWindow(frame: (UIApplication.sharedApplication().keyWindow?.bounds)!)
...
}
Objective-C
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
...
self.window =
[[MDCOverlayWindow alloc] initWithFrame:[UIApplication sharedApplication].keyWindow.bounds];
...
}
Using the Overlay Window
Once the Overlay Window is set in the App Delegate, the client can use the Overlay Window to display views at the top most level of the view hierarchy.
Swift
let overlayView = UIView()
...
// Set up view to be displayed in the overlay window.
...
if (self.window?.isKindOfClass(UIWindow) != nil) {
overlayWindow.activateOverlay(overlayView, level:UIWindowLevelNormal)
}
Objective-C
UIView *overlayView = [UIView alloc] init];
...
// Set up view to be displayed in the overlay window.
...
if ([window isKindOfClass:[MDCOverlayWindow class]]) {
MDCOverlayWindow *overlayWindow = (MDCOverlayWindow *)window;
[overlayWindow activateOverlay:overlayView withLevel:UIWindowLevelNormal];
}