Last active
June 18, 2019 14:53
-
-
Save AkdM/964d59d1a9060393bde0ed8353dd121b to your computer and use it in GitHub Desktop.
Swift Playground: Corner Radius + Shadow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import PlaygroundSupport | |
// For the Playground only: creating an UIView where the next UIView will be shown on | |
let container = UIView(frame: CGRect(x: 0, y: 0, width: 500, height: 500)) | |
container.backgroundColor = .white | |
// The interesting stuff | |
let viewShadow = UIView(frame: CGRect(x: 0, y: 0, width: 120, height: 120)) | |
viewShadow.center = container.center | |
viewShadow.backgroundColor = UIColor.white | |
viewShadow.layer.shadowColor = UIColor.black.cgColor | |
viewShadow.layer.shadowOpacity = 0.3 | |
viewShadow.layer.shadowOffset = CGSize(width: 0, height: 8.0) // width = x; height = y | |
viewShadow.layer.shadowRadius = 10 | |
viewShadow.layer.cornerRadius = 10 | |
container.addSubview(viewShadow) | |
// For the Playground only: showing it on the Assistant Editor (CMD+Enter to show) | |
PlaygroundPage.current.liveView = container | |
PlaygroundPage.current.needsIndefiniteExecution = true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment