mobile-ios/CovidSafe/UIImage+imageColor.swift

24 lines
770 B
Swift
Raw Permalink Normal View History

2021-02-26 03:41:20 +00:00
//
// UIImage+imageColor.swift
// CovidSafe
//
// Copyright © 2021 Australian Government. All rights reserved.
//
import UIKit
extension UIImage {
class func imageWithColor(color: UIColor, topBorderColor: UIColor, size: CGSize) -> UIImage {
let rect: CGRect = CGRect(x: 0.0, y: 0.0, width: Double(size.width), height: Double(size.height))
let topRect: CGRect = CGRect(x: 0.0, y: 0.0, width: Double(size.width), height: Double(3.0))
UIGraphicsBeginImageContextWithOptions(size, false, 0)
color.setFill()
UIRectFill(rect)
topBorderColor.setFill()
UIRectFill(topRect)
let image: UIImage = UIGraphicsGetImageFromCurrentImageContext()!
UIGraphicsEndImageContext()
return image
}
}