An iOS Library that makes shadows management easy on UIView.

Overview

ShadowView is an iOS Shadow library that makes view's shadow implementation easy and sweet πŸŽ‰ 🎊 .

Swift Version Build Status License CocoaPods Compatible Platform


Add simple shadows to add a gaussian blurred projection (as a shadow) to any UIView.

Table of contents

Features

  • Add shadow easily from the storyboard and programmatically.
  • Add a gaussian blurred projection of your view (like iOS 10 music app).
  • Customize the border width and border color of any view from storyboard .

Requirements

  • iOS 9.0+
  • Xcode 8

Installation

CocoaPods

You can use CocoaPods to install ShadowView by adding it to your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!

target '<Your Target Name>' do
pod 'ShadowView'
end

Carthage

  1. Install Carthage via Homebrew
$ brew update
$ brew install carthage
  1. Add github "PierrePerrin/ShadowView" to your Cartfile.

  2. Run carthage update.

  3. Drag ShadowView.framework from the Carthage/Build/iOS/ directory to the Linked Frameworks and Libraries section of your Xcode project’s General settings.

  4. Add $(SRCROOT)/Carthage/Build/iOS/ShadowView.framework to Input Files of Run Script Phase for Carthage.

Manually

  1. Download and drop all files in ShadowView directory in your project.
  2. Nice Job the best shadow library is now installed! πŸŽ‰ 🎊 🎈

Import

To get the full benefits import ShadowView wherever you import UIKit

import UIKit
import ShadowView

How it works

Normal Shadows

This shadow framework uses default CoreGraphics shadows by adding it the the layer of the view.

layer.shadowColor : CGColor
layer.shadowRadius : CGFloat
layer.shadowOffset : CGSize
layer.shadowOpacity : Float
layer.shadowPath : CGPath?

Projected Gaussian Shadows

Here the implemation is different. A shadow container need to be added and all views that needs a blurred shadow need to be subviews of this container. The container takes a screen of all it's subviews and then apply blur on it.

Usage example

With Storyboard

Normal Shadows

Any view has new paramerters in the storyboar that you can change in order to add a customize shadow to your view.

Projected Gaussian Shadows

Add an UIView to you ViewController, change it class to ShadowView and insert in it all view that needs a blurred shadow.

Programmatically

Normal Shadows

Set the shadows parameters to your view and it the shadow will appear! 🌟

view.shadowRadius = 5
view.shadowOffset = CGSize.zero
view.shadowColor = UIColor.black.cgColor
view.shadowOpacity = 0.3

Projected Gaussian Shadows

Create you container ShadowView and then add views that need Shadows inside of it.

    let exampleShadowContainerView = ShadowView()
    let imageView = UIImageView(image: #imageLiteral(resourceName: "sample.jpg"))

    override func loadView() {
        super.loadView()

        exampleShadowContainerView.frame = self.view.bounds
        exampleShadowContainerView.autoresizingMask = [.flexibleWidth,.flexibleHeight]
        exampleShadowContainerView.shadowOffset = CGSize(width: 0, height: 10)
        exampleShadowContainerView.shadowRadius = 20

        self.view.addSubview(exampleShadowContainerView)
        self.exampleShadowContainerView.addSubview(imageView)
        imageView.center = exampleShadowContainerView.center
    }

    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        imageView.frame.size = CGSize(width: 200, height: 200)
        imageView.center = exampleShadowContainerView.center
        self.exampleShadowContainerView.updateShadow()
    }

Please see the example for more prescisions.

Parameters

//Shared Paramerters

@IBInspectable public var shadowRadius : CGFloat

@IBInspectable public var shadowOffset : CGSize

@IBInspectable public var shadowColor : UIColor?

@IBInspectable public var shadowOpacity : Float

//Normal Shadow

@IBInspectable var shadowPath : CGPath?

//ShadowView only

///It changes the size of the projected shadow view.
@IBInspectable var shadowScale : CGFloat

///Changes the tint color of the blurred image
@IBInspectable var shadowTintColor : UIColor

///Changes the saturation of the blurred image (default:1)
@IBInspectable var shadowSaturation : CGFloat

Notes

Don't use Views like Sliders or ActivityIndicators, the shadow don't update un real-time. It's preferable to use statics Views like Labels, images...

Contribute

We would love you for the contribution to ShadowView, check the LICENSE file for more info. If you find an issue, open a ticket on it.

Meta

Pierre Perrin – [email protected]

Distributed under the MIT license. See LICENSE for more information.

https://github.com/PierrePerrin/

You might also like...
High performance and lightweight UIView, UIImage, UIImageView, UIlabel, UIButton, Promise and more.

SwiftyUI High performance and lightweight UIView, UIImage, UIImageView, UIlabel, UIButton and more. Features SwiftyView GPU rendering Image and Color

A framework which helps you attach observers to `UIView`s to get updates on its frame changes

FrameObserver is a framework that lets you attach observers to any UIView subclass and get notified when its size changes. It doesn't use any Method S

Easily use UIKit views in your SwiftUI applications. Create Xcode Previews for UIView elements
Easily use UIKit views in your SwiftUI applications. Create Xcode Previews for UIView elements

SwiftUIKitView Easily use UIKit views in SwiftUI. Convert UIView to SwiftUI View Create Xcode Previews from UIView elements SwiftUI functional updatin

A swift PropertyWrapper to provide automatic NSView/UIView invalidation when the properties value changes.

A swift PropertyWrapper to provide automatic NSView/UIView invalidation when the properties value changes. It duplicates the @Invalidating propertyWrapper for build targets prior to macOS 12 and iOS 15.

πŸ“Ή Framework to Play a Video in the Background of any UIView
πŸ“Ή Framework to Play a Video in the Background of any UIView

SwiftVideoBackground is an easy to use Swift framework that provides the ability to play a video on any UIView. This provides a beautiful UI for login

Anchorage - Single file UIView drag and drop system
Anchorage - Single file UIView drag and drop system

anchorage Single file UIView drag and drop system anchors.mp4 License Copyright

Powerful and easy-to-use vector graphics Swift library with SVG support
Powerful and easy-to-use vector graphics Swift library with SVG support

Macaw Powerful and easy-to-use vector graphics Swift library with SVG support We are a development agency building phenomenal apps. What is Macaw? Mac

An easy to use FAQ view for iOS written in Swift
An easy to use FAQ view for iOS written in Swift

FAQView An easy to use FAQ view for iOS written in Swift. This view is a subclass of UIView. Setup with CocoaPods If you are using CocoaPods add this

UIPheonix is a super easy, flexible, dynamic and highly scalable UI framework + concept for building reusable component/control-driven apps for macOS, iOS and tvOS
UIPheonix is a super easy, flexible, dynamic and highly scalable UI framework + concept for building reusable component/control-driven apps for macOS, iOS and tvOS

UIPheonix is a super easy, flexible, dynamic and highly scalable UI framework + concept for building reusable component/control-driven apps for macOS, iOS and tvOS

Comments
  • addSubview so lag

    addSubview so lag

    When I add the shadowContainerView be the subview. It's so slow and feel lag.

    ShadowView *shadowContainerView = [[ShadowView alloc] init]; shadowContainerView.frame = self.bounds; shadowContainerView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight); shadowContainerView.shadowOffset = CGSizeMake(0, self.shadowOffset); shadowContainerView.shadowRadius = self.radius; shadowContainerView.shadowScale = 0.9;

    CGRect frame = self.frame; frame.size.height = self.height+self.shadowOffset; self.frame = frame;

    [self addSubview: shadowContainerView]; //this line make the program so slow and lag [shadowContainerView addSubview:_frontImgView]; _frontImgView.center = shadowContainerView.center;

    opened by fung199609 2
  • Is it still working?

    Is it still working?

    I tried to use it with a collection view I could'n find the: shadowView.highPerformanceBlur Could you give more detailed info about how to use it programmatically? I would love to use this framework, it seems awesome!

    opened by leo1mml 2
  • Shadow generation too long

    Shadow generation too long

    Hello! I add ShadowView in my TableViewCell, but shadow generation is too long. ================================================================= Main Thread Checker: UI API called on a background thread: -[UIView layer] PID: 70222, TID: 17479263, Thread name: (none), Queue name: com.apple.root.utility-qos, QoS: 17 Backtrace: 4 ShadowView 0x000000010afb5e5d _T0So6UIViewC10ShadowViewE7asImageSo7UIImageCfg + 29 5 ShadowView 0x000000010afabf1d _T010ShadowViewAAC16createLayerImage33_9B9E92D7988F296C5B194A5602A768AFLLyyF + 61 6 ShadowView 0x000000010afabe96 _T010ShadowViewAAC06updateA0yyFyycfU_ + 150 7 ShadowView 0x000000010afabedc _T010ShadowViewAAC06updateA0yyFyycfU_TA + 12 8 ShadowView 0x000000010afacad9 _T0Ix_IyB_TR + 41 9 libdispatch.dylib 0x000000010f6f63f7 _dispatch_call_block_and_release + 12 10 libdispatch.dylib 0x000000010f6f743c _dispatch_client_callout + 8 11 libdispatch.dylib 0x000000010f703499 _dispatch_root_queue_drain + 1444 12 libdispatch.dylib 0x000000010f702e97 _dispatch_worker_thread3 + 132 13 libsystem_pthread.dylib 0x000000010fbba5a2 _pthread_wqthread + 1299 14 libsystem_pthread.dylib 0x000000010fbba07d start_wqthread + 13

    opened by axmav 2
Releases(1.4.1)
Shadow - Syntactic sugar for shadows in the SwiftUI framework

Shadow Syntactic sugar for shadows in the SwiftUI framework. import SwiftUI impo

Dima Koskin 2 Jan 31, 2022
Twinkle is a Swift and easy way to make any UIView in your iOS or tvOS app twinkle.

Twinkle ✨ Twinkle is a Swift and easy way to make any UIView in your iOS or tvOS app twinkle. This library creates several CAEmitterLayers and animate

patrick piemonte 600 Nov 24, 2022
A child view controller framework that makes setting up your parent controllers as easy as pie.

Description Family is a child view controller framework that makes setting up your parent controllers as easy as pie. With a simple yet powerful publi

Christoffer Winterkvist 246 Dec 28, 2022
Windless makes it easy to implement invisible layout loading view.

Windless Windless makes it easy to implement invisible layout loading view. Contents Requirements Installation Usage Looks Credits Communication Licen

ArLupin 940 Dec 22, 2022
A UIControl subclass that makes it easy to create empty states.

AZEmptyState Making empty state simple. Screenshots Installation Cocoa Pods: pod 'AZEmptyState' Manual: Simply drag and drop the Sources folder to you

Antonio Zaitoun 88 Oct 2, 2022
A drop-in universal library helps you to manage the navigation bar styles and makes transition animations smooth between different navigation bar styles

A drop-in universal library helps you to manage the navigation bar styles and makes transition animations smooth between different navigation bar styles while pushing or popping a view controller for all orientations. And you don't need to write any line of code for it, it all happens automatically.

Zhouqi Mo 3.3k Dec 21, 2022
Custom Beautiful UIView For Handling IDs in iOS

IDView Custom Beautiful UIView For Handling IDs in iOS Setup Set the placeholder images for the front and back faces. override func viewDidLoad()

Omar Labib 6 Aug 21, 2021
Simple battery shaped UIView

BatteryView Simple battery shaped UIView. Usage let batteryView = BatteryView(frame: smallRect) batteryView.level = 42 // anywhere in 0...100 batteryV

Yonat Sharon 50 Sep 19, 2022
Elissa displays a notification on top of a UITabBarItem or any UIView anchor view to reveal additional information.

Elissa Attach a local notification to any UIView to reveal additional user guidance. Usage Example Per default, Elissa will try to align to the center

null 169 Aug 14, 2022
UIView and CGRect extension that adds properties to manipulate them efficiently

Geometry Geometry is a UIView and CGRect extension that lets you work with view and rect geometry easier. It adds the following properties to UIView:

Tuomas Artman 92 Sep 7, 2022