Skip to content

Instantly share code, notes, and snippets.

@elu697
Created September 24, 2018 10:52
Show Gist options
  • Select an option

  • Save elu697/5e081337214a03171a0cd0508dfa6976 to your computer and use it in GitHub Desktop.

Select an option

Save elu697/5e081337214a03171a0cd0508dfa6976 to your computer and use it in GitHub Desktop.
UIViewやUIButtonに影をつける ref: https://qiita.com/ammYou/items/f688a5239c1edb16be01
import Foundation
import UIKit
public extension CALayer {
enum Direction {
case top
case bottom
}
public func addShadow(direction: Direction){
switch direction {
case .top:
self.shadowOffset = CGSize(width: 0.0, height: -1)
case .bottom:
self.shadowOffset = CGSize(width: 0.0, height: 1)
}
self.shadowRadius = 1.5
self.shadowColor = UIColor.black
self.shadowOpacity = 0.5
}
}
self.menuBarView.layer.addShadow(direction: .bottom)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment