问题 I get gradient image with this method func gradient(size:CGSize,color:[UIColor]) -> UIImage?{ //turn color into cgcolor let colors = color.map{$0.cgColor} //begin graphics context UIGraphicsBeginImageContextWithOptions(size, true, 0.0) guard let context = UIGraphicsGetCurrentContext() else { return nil } // From now on, the context gets ended if any return happens defer {UIGraphicsEndImageContext()} //create core graphics context let locations:[CGFloat] = [0.0,1.0] guard let gredient =