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
Before using Shadow Elevations, you'll need to import it:
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 } }
#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