mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Implement default timeline avatar. Issue #641
This commit is contained in:
@@ -24,12 +24,12 @@ struct AppAssets {
|
||||
|
||||
static var chevronDownImage: RSImage = {
|
||||
let image = RSImage(named: "chevronDownImage")!
|
||||
return image.maskWithColor(color: AppAssets.chevronDisclosureColor)!
|
||||
return image.maskWithColor(color: AppAssets.chevronDisclosureColor.cgColor)!
|
||||
}()
|
||||
|
||||
static var chevronRightImage: RSImage = {
|
||||
let image = RSImage(named: "chevronRightImage")!
|
||||
return image.maskWithColor(color: AppAssets.chevronDisclosureColor)!
|
||||
return image.maskWithColor(color: AppAssets.chevronDisclosureColor.cgColor)!
|
||||
}()
|
||||
|
||||
static var faviconTemplateImage: RSImage = {
|
||||
@@ -42,7 +42,7 @@ struct AppAssets {
|
||||
|
||||
static var feedImage: RSImage = {
|
||||
let image = RSImage(named: "feedImage")!
|
||||
return image.maskWithColor(color: AppAssets.feedColor)!
|
||||
return image.maskWithColor(color: AppAssets.feedColor.cgColor)!
|
||||
}()
|
||||
|
||||
static var masterFolderColor: UIColor = {
|
||||
@@ -51,7 +51,7 @@ struct AppAssets {
|
||||
|
||||
static var masterFolderImage: RSImage = {
|
||||
let image = RSImage(named: "folderImage")!
|
||||
return image.maskWithColor(color: AppAssets.masterFolderColor)!
|
||||
return image.maskWithColor(color: AppAssets.masterFolderColor.cgColor)!
|
||||
}()
|
||||
|
||||
static var selectionBackgroundColor: UIColor = {
|
||||
@@ -64,7 +64,7 @@ struct AppAssets {
|
||||
|
||||
static var smartFeedImage: RSImage = {
|
||||
let image = RSImage(named: "smartFeedImage")!
|
||||
return image.maskWithColor(color: AppAssets.smartFeedColor)!
|
||||
return image.maskWithColor(color: AppAssets.smartFeedColor.cgColor)!
|
||||
}()
|
||||
|
||||
static var starColor: UIColor = {
|
||||
@@ -81,7 +81,7 @@ struct AppAssets {
|
||||
|
||||
static var timelineStarImage: RSImage = {
|
||||
let image = RSImage(named: "starClosedImage")!
|
||||
return image.maskWithColor(color: AppAssets.starColor)!
|
||||
return image.maskWithColor(color: AppAssets.starColor.cgColor)!
|
||||
}()
|
||||
|
||||
static var timelineTextPrimaryColor: UIColor = {
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
//
|
||||
// UIImage-Extensions.swift
|
||||
// NetNewsWire
|
||||
//
|
||||
// Created by Maurice Parker on 4/18/19.
|
||||
// Copyright © 2019 Ranchero Software. 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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user