Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@FromAtom
Created May 2, 2018 06:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FromAtom/f078bbe73301ec6a4e2e12a1b3ec62de to your computer and use it in GitHub Desktop.
Save FromAtom/f078bbe73301ec6a4e2e12a1b3ec62de to your computer and use it in GitHub Desktop.
TableViewの上下を透明グラデーションにする
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
let gradient = CAGradientLayer()
gradient.frame = tableView.superview?.bounds ?? .null
gradient.colors = [UIColor.clear.cgColor, UIColor.black.cgColor, UIColor.black.cgColor, UIColor.clear.cgColor]
gradient.locations = [0.0, 0.1, 0.9, 1.0]
tableView.superview?.layer.mask = gradient
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment