Home>

An error occurred in the following code, but the cause is unknown.

import Foundation
import UIKit
class ChangeColor {
  func changeColor (topR: CGfloat, topG: CGfloat, topB: CGfloat, topAlpha: CGfloat,
                   bottomR: CGfloat, bottomG: CGfloat, bottomB: CGfloat, bottomAlpha: CGfloat)->CAGradientLayer {
    // Gradient start color
    let topColor = UIColor (red: topR, green: topG, blue: topB, alpha: topAlpha)
    let bottomColor = UIColor (red: bottomR, green: bottomG, blue: bottomB, alpha: bottomAlpha)
   // Manage gradient colors in an array
    let gradientColor = [topColor.cgColor, bottomColor.cgColor]
    let gradientLayer = CAGradientLayer ()
    gradientLayer.colors = gradientColor
    return gradientLayer
  }
}


The contents of the error are "Use of undeclared type 'CGfloat'" in the place of the functionchangeColor, and "Expected initial value after '='" in the part where the gradation color of the comment is written for some reason. I got out.
I looked at it from the error content and it seemed that there were no elements that could cause the error.
I don't know why this error has occurred, so I would appreciate your advice.

Addition
When I built it again, the second "Expected initial value after '='" error was gone.