https://github.com/anthonylatsis/sombra
A simple retroaction on CALayer to support vibrant image projections as shadows.
https://github.com/anthonylatsis/sombra
calayer image ios layer shadow shadows swift xcode
Last synced: 12 months ago
JSON representation
A simple retroaction on CALayer to support vibrant image projections as shadows.
- Host: GitHub
- URL: https://github.com/anthonylatsis/sombra
- Owner: AnthonyLatsis
- License: mit
- Created: 2018-07-12T22:44:39.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-07-18T17:42:22.000Z (over 7 years ago)
- Last Synced: 2025-03-09T18:46:48.829Z (about 1 year ago)
- Topics: calayer, image, ios, layer, shadow, shadows, swift, xcode
- Language: Swift
- Homepage:
- Size: 24.4 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Sombra
A light native-style retroaction on `CALayer` to support vibrant image projections as shadows.
## Usage
To have an image projection instead of a plane color as a shadow, you use `shadowImage`. The rest is set up the usual way using existing shadow properties.
``` swift
view.layer.shadowOpacity = 0.8
view.layer.shadowOffset = CGSize(width: 0, height: 15)
view.layer.shadowRadius = 30
view.layer.shadowImage = UIImage().cgImage
```
### Considerations
While using an image projection as a shadow, the value of `shadowOpacity` will be cached and the property itself set to zero. This is done for the regular shadow not to appear. Setting the image to `nil` will leave you with a regular shadow, if any (`shadowOpacity > 0`).
The image projection currently doesn't support animating through shadow properties.
## Requirements
* Xcode 9 +
* Swift 4 +
* iOS 10 +
## Installation
Sombra can be integrated using [CocoaPods](https://cocoapods.org/). Specify it in your `Podfile` and run `$ pod install`.
``` ruby
platform :ios, '10.0'
use_frameworks!
target '' do
pod 'Sombra'
end
```