//传递颜色,size返回image
func imageFromColor(color: UIColor, viewSize: CGSize) -> UIImage{
let rect: CGRect = CGRect(x: 0, y: 0, width: viewSize.width, height: viewSize.height)
UIGraphicsBeginImageContext(rect.size)
let context: CGContext = UIGraphicsGetCurrentContext()!
context.setFillColor(color.cgColor)
context.fill(rect)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsGetCurrentContext()
return image!
}