Skip to content

Instantly share code, notes, and snippets.

@victorBaro
Created October 18, 2015 21:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save victorBaro/b0600eb98ee6415d0497 to your computer and use it in GitHub Desktop.
Save victorBaro/b0600eb98ee6415d0497 to your computer and use it in GitHub Desktop.
Function for controlling button's shadow based on input force
func shadowWithAmount(amount: CGFloat) {
self.layer.shadowColor = shadowColor.CGColor
self.layer.shadowOpacity = shadowOpacity
let widthFactor = maxShadowOffset.width/maxForceValue
let heightFactor = maxShadowOffset.height/maxForceValue
self.layer.shadowOffset = CGSize(width: maxShadowOffset.width - amount * widthFactor, height: maxShadowOffset.height - amount * heightFactor)
self.layer.shadowRadius = maxShadowRadius - amount
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment