Added initial POC version of NetNewsWire for iOS to use as a starting point for the actual app.

This commit is contained in:
Maurice Parker
2019-04-15 15:03:05 -05:00
parent 8f1f153e98
commit 8526db8b4c
47 changed files with 4454 additions and 220 deletions

View File

@@ -0,0 +1,32 @@
//Copyright © 2019 Vincode, Inc. All rights reserved.
import UIKit
extension UIImage {
func maskWithColor(color: UIColor) -> UIImage? {
let maskImage = cgImage!
let width = size.width
let height = size.height
let bounds = CGRect(x: 0, y: 0, width: width, height: height)
let colorSpace = CGColorSpaceCreateDeviceRGB()
let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.premultipliedLast.rawValue)
let context = CGContext(data: nil, width: Int(width), height: Int(height), bitsPerComponent: 8, bytesPerRow: 0, space: colorSpace, bitmapInfo: bitmapInfo.rawValue)!
context.clip(to: bounds, mask: maskImage)
context.setFillColor(color.cgColor)
context.fill(bounds)
if let cgImage = context.makeImage() {
let coloredImage = UIImage(cgImage: cgImage)
return coloredImage
} else {
return nil
}
}
}