//根据颜色创建UIImage
funccreatImageWithColor(color:UIColor)->UIImage{
letrect =CGRect.init(x:0, y:0, width:1.0, height:1.0)
UIGraphicsBeginImageContext(rect.size)
letcontext =UIGraphicsGetCurrentContext()
context!.setFillColor(color.cgColor)
context!.fill(rect)
letimage =UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
returnimage!
}