A former prototyping project has been ported to swift 3 -- a view controller with looped gradient background. These gradient properties can be edited in IB.
Currently the background gradient contains two colors. And these colors are divided into several colors to present the "loop" effect.
GradientView supports:
- Gradient of 2 colors with user defined angle
- Device orientation
- Animation will be restored when view reappearing
Simply add GradientView.swift to the project.
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if gradient == nil {
gradient = GradientView(frame: self.view.bounds, hexColor1: "#F298e7", hexColor2: "#a5f9f9", angle: 25.0)
view.addSubview(gradient)
view.sendSubview(toBack: gradient)
gradient.isUserInteractionEnabled = false
} else {
gradient.start()
}
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
if gradient != nil {
gradient.stop()
}
}- IBColor1
- IBColor2
- Angle : gradient angle (impletemented by startPoint and endPoint)
- Loop Duration : duration for animation

