Swiftgram/submodules/Charts/Sources/Helpers/UIImage+Utils.swift
2020-02-11 10:34:00 +04:00

29 lines
818 B
Swift

//
// UIImage+Utils.swift
// GraphTest
//
// Created by Andrei Salavei on 4/8/19.
// Copyright © 2019 Andrei Salavei. All rights reserved.
//
import UIKit
extension UIImage {
static let arrowRight = UIImage(bundleImageName: "Chart/arrow_right")
static let arrowLeft = UIImage(bundleImageName: "Chart/arrow_left")
public convenience init?(color: UIColor, size: CGSize = CGSize(width: 1, height: 1)) {
let rect = CGRect(origin: .zero, size: size)
UIGraphicsBeginImageContextWithOptions(rect.size, false, 0.0)
color.setFill()
UIRectFill(rect)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
guard let cgImage = image?.cgImage else { return nil }
self.init(cgImage: cgImage)
}
}