0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Swift】SlideshowAppで学んだこと

Posted at

はじめに

SlideshowAppを作成しましたので、そこで学んだことの備忘録です。

GitHub

学んだこと

グラデーションの扱いです。

let width = self.view.frame.size.width
let height = self.view.frame.size.height
let gradientLayer = CAGradientLayer()
gradientLayer.frame = CGRect(x: 0, y: 0, width: width, height: height)
gradientLayer.colors = [UIColor(red: 0.8, green: 0.0, blue: 0.73, alpha: 1).cgColor,
                        UIColor(red: 0.1, green: 0.0, blue: 0.40, alpha: 1).cgColor]
gradientLayer.startPoint = CGPoint.init(x: 0, y: 0.5)
gradientLayer.endPoint = CGPoint.init(x: 1, y: 0.5)
self.view.layer.insertSublayer(gradientLayer, at: 0)

このようにすることで、背景色がグラデーションでいい感じになってくれます。
公式ドキュメント: CAGradientLayer
スニペットなどに登録しておくことをお勧めします!

おわりに 

おわりです。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?