tree: 65535dc232ef28bcb530a2dae0c40a93fbed0965 [path history] [tgz]
  1. examples/
  2. src/
  3. .jazzy.yaml
  4. README.md
components/ShadowElevations/README.md

Shadow Elevations

A shadow elevation specifies the degree of shadow intensity to be displayed beneath an object. Higher shadow elevations have greater shadow intensities, akin to raising an object above a surface resulting in a more prominent, albeit more diffuse, shadow. This component provides commonly used Material Design elevations for components.

Design & API Documentation


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/ShadowElevations'

Then, run the following command:

pod install

Usage

Importing

Before using Shadow Elevations, you'll need to import it:

Swift

import MaterialComponents

class ShadowedView: UIView {

  override class var layerClass: AnyClass {
    return MDCShadowLayer.self
  }

  var shadowLayer: MDCShadowLayer {
    return self.layer as! MDCShadowLayer
  }

  func setDefaultElevation() {
    self.shadowLayer.elevation = MDCShadowElevationCardResting
  }

}

Objective-C

#import "MaterialShadowElevations.h"

@interface ShadowedView: UIView

@end

@implementation ShadowedView

+ (Class)layerClass {
  return [MDCShadowLayer class];
}

- (MDCShadowLayer *)shadowLayer {
  return (MDCShadowLayer *)self.layer;
}

- (void)setDefaultElevation {
  self.shadowLayer.elevation = MDCShadowElevationCardResting;
}

@end