Git Product home page Git Product logo

swiftyshadow's Introduction

SwiftyShadow

Codacy Badge

Helper Libraries to generate wonderful shadow in Swift iOS.

Screenshots

Requirements

  • iOS 8.0+
  • Xcode 8+
  • Swift 4.2

Installation

CocoaPods

To integrate PhotoCollectionView into your Xcode project using CocoaPods, specify it in your Podfile:

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

pod 'SwiftyShadow', '~> 1.7.0'

Then, run the following command:

$ pod install

Manually

  • Drag and drop Sources folder into your project.

Usage

Inner Shadow in View

Use SwiftyInnerShadowView class as UIView to make this View has inner shadow.

  • Use Storyboard

Set SwiftyInnerShadowView as UIView Class in the storyboard:

then make an outlet

@IBOutlet weak var testView: SwiftyInnerShadowView!
  • inner shadow properties Set inner shadow propeties through shadowLayer of SwiftyInnerShadowView
testView.shadowLayer.shadowRadius = 4
testView.shadowLayer.shadowColor = UIColor.red.cgColor
testView.shadowLayer.shadowOpacity = 0.8
testView.shadowLayer.shadowOffset = CGSize.zero
testView.cornerRadius = 120

Outer Shadow in View

You can set up outer shadow in view with default properties in UIView

imageView.layer.cornerRadius = 120
imageView.layer.shadowRadius = 20
imageView.layer.shadowOpacity = 0.8
imageView.layer.shadowColor = UIColor.black.cgColor
imageView.layer.shadowOffset = CGSize.zero

but shadow doesn't work if view has clipsToBounds = true, so just call generateOuterShadow function

imageView.generateOuterShadow()

Elliptical Shadow

You need set up shadow properties first, then call generateEllipticalShadow

imageView.layer.shadowRadius = 20
imageView.layer.shadowOpacity = 0.8
imageView.layer.shadowColor = UIColor.black.cgColor
imageView.layer.shadowOffset = CGSize.zero
        
imageView.generateEllipticalShadow()

TODO

Todo

License

MIT

swiftyshadow's People

Contributors

codacy-badger avatar crspybits avatar fvolchyok avatar noblakit01 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

swiftyshadow's Issues

view.layer.shadowOffset is hardcoded to CGSize.zero

Hello, UIView.generateOuterShadow() always sets the shadow directly underneath the view, and ignores the view's layer.shadowOffset.

Line 20 of UIView.swift generateOuterShadow() currently is:

    view.layer.shadowOffset = CGSize.zero

Should be updated to:

  view.layer.shadowOffset = layer.shadowOffset

In order to be able to position the outer shadow horizontally or vertically. I'll be happy to submit a pull request if you'd like.

black stripe

When using the following parameters - the view starts to add a black bar at the bottom
IMG_0039

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.