lzj_singleDotImage的来源
import UIKit
extension UIImage {
/// 创建一个`点`的图像
class func lzj_singleDotImage(color: UIColor) ->UIImage {
// 1. 开启上下文,需要注意 scale
UIGraphicsBeginImageContextWithOptions(CGSize(width: 1, height: 1), false , UIScreen.mainScreen().scale)
//画图,填充颜色
color.setFill()
UIRectFill(CGRect(x: 0, y: 0, width: 1, height: 1))
//从上下文中获取图片
let image = UIGraphicsGetImageFromCurrentImageContext()
//关闭上下文
UIGraphicsEndImageContext()
//返回
return image
}
}