remove convenience inits
This commit is contained in:
parent
b8fb0b2b41
commit
cb9084060f
|
|
@ -1,6 +1,6 @@
|
|||
Pod::Spec.new do |s|
|
||||
s.name = "LeadKit"
|
||||
s.version = "0.3.1"
|
||||
s.version = "0.3.2"
|
||||
s.summary = "iOS framework with a bunch of tools for rapid development"
|
||||
s.homepage = "https://github.com/TouchInstinct/LeadKit"
|
||||
s.license = "Apache License, Version 2.0"
|
||||
|
|
|
|||
|
|
@ -25,22 +25,23 @@ import CoreGraphics
|
|||
public extension CGContext {
|
||||
|
||||
/**
|
||||
creates an instance of CGContext with parameters taken from a given image
|
||||
method which creates an instance of CGContext with parameters taken from a given image
|
||||
|
||||
- parameter forCGImage: CGImage instance from which the parameters will be taken
|
||||
- parameter fallbackColorSpace: fallback color space if image doesn't have it
|
||||
*/
|
||||
public convenience init?(forCGImage cgImage: CGImage,
|
||||
fallbackColorSpace: CGColorSpace = CGColorSpaceCreateDeviceRGB()) {
|
||||
self.init(width: cgImage.width,
|
||||
height: cgImage.height,
|
||||
bitmapInfo: cgImage.bitmapInfo,
|
||||
colorSpace: cgImage.colorSpace ?? fallbackColorSpace,
|
||||
bitsPerComponent: cgImage.bitsPerComponent)
|
||||
public static func create(forCGImage cgImage: CGImage,
|
||||
fallbackColorSpace: CGColorSpace = CGColorSpaceCreateDeviceRGB()) -> CGContext? {
|
||||
|
||||
return create(width: cgImage.width,
|
||||
height: cgImage.height,
|
||||
bitmapInfo: cgImage.bitmapInfo,
|
||||
colorSpace: cgImage.colorSpace ?? fallbackColorSpace,
|
||||
bitsPerComponent: cgImage.bitsPerComponent)
|
||||
}
|
||||
|
||||
/**
|
||||
creates an instance of CGContext
|
||||
method which creates an instance of CGContext
|
||||
|
||||
- parameter width: The width, in pixels, of the required bitmap.
|
||||
- parameter height: The height, in pixels, of the required bitmap.
|
||||
|
|
@ -50,18 +51,19 @@ public extension CGContext {
|
|||
- parameter colorSpace: The color space to use for the bitmap context.
|
||||
- parameter bitsPerComponent: The number of bits to use for each component of a pixel in memory.
|
||||
*/
|
||||
public convenience init?(width: Int,
|
||||
height: Int,
|
||||
bitmapInfo: CGBitmapInfo = alphaBitmapInfo,
|
||||
colorSpace: CGColorSpace = CGColorSpaceCreateDeviceRGB(),
|
||||
bitsPerComponent: Int = 8) {
|
||||
self.init(data: nil,
|
||||
width: width,
|
||||
height: height,
|
||||
bitsPerComponent: bitsPerComponent,
|
||||
bytesPerRow: 0,
|
||||
space: colorSpace,
|
||||
bitmapInfo: bitmapInfo.rawValue)
|
||||
}
|
||||
public static func create(width: Int,
|
||||
height: Int,
|
||||
bitmapInfo: CGBitmapInfo = alphaBitmapInfo,
|
||||
colorSpace: CGColorSpace = CGColorSpaceCreateDeviceRGB(),
|
||||
bitsPerComponent: Int = 8) -> CGContext? {
|
||||
|
||||
return CGContext(data: nil,
|
||||
width: width,
|
||||
height: height,
|
||||
bitsPerComponent: bitsPerComponent,
|
||||
bytesPerRow: 0,
|
||||
space: colorSpace,
|
||||
bitmapInfo: bitmapInfo.rawValue)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public extension CGImage {
|
|||
return self
|
||||
}
|
||||
|
||||
let ctx = CGContext(width: width, height: height, bitmapInfo: alphaBitmapInfo)
|
||||
let ctx = CGContext.create(width: width, height: height, bitmapInfo: alphaBitmapInfo)
|
||||
ctx?.draw(self, in: bounds)
|
||||
|
||||
return ctx?.makeImage()
|
||||
|
|
|
|||
|
|
@ -39,9 +39,9 @@ public extension CGImage {
|
|||
height: Int,
|
||||
opaque: Bool = false) -> CGImage? {
|
||||
|
||||
let context = CGContext(width: width,
|
||||
height: height,
|
||||
bitmapInfo: opaque ? opaqueBitmapInfo : alphaBitmapInfo)
|
||||
let context = CGContext.create(width: width,
|
||||
height: height,
|
||||
bitmapInfo: opaque ? opaqueBitmapInfo : alphaBitmapInfo)
|
||||
|
||||
guard let ctx = context else {
|
||||
return nil
|
||||
|
|
@ -66,7 +66,7 @@ public extension CGImage {
|
|||
let ctxWidth = Int(ceil(size.width))
|
||||
let ctxHeight = Int(ceil(size.height))
|
||||
|
||||
guard let ctx = CGContext(width: ctxWidth, height: ctxHeight) else {
|
||||
guard let ctx = CGContext.create(width: ctxWidth, height: ctxHeight) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public extension CGImage {
|
|||
- returns: new CGImage rendered with given color or nil if something goes wrong
|
||||
*/
|
||||
public func renderTemplate(withColor color: CGColor) -> CGImage? {
|
||||
guard let ctx = CGContext(forCGImage: self) ?? CGContext(width: width, height: height) else {
|
||||
guard let ctx = CGContext.create(forCGImage: self) ?? CGContext.create(width: width, height: height) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public extension CGImage {
|
|||
- returns: A new image
|
||||
*/
|
||||
public func round(withRadius radius: CGFloat) -> CGImage? {
|
||||
guard let ctx = CGContext(forCGImage: self) ?? CGContext(width: width, height: height) else {
|
||||
guard let ctx = CGContext.create(forCGImage: self) ?? CGContext.create(width: width, height: height) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -68,13 +68,13 @@ public extension CGImage {
|
|||
|
||||
let ctxRect: CGRect = CGRect(origin: CGPoint.zero, size: CGSize(width: newWidth, height: newHeight))
|
||||
|
||||
let context = CGContext(width: ctxWidth,
|
||||
height: ctxHeight,
|
||||
bitmapInfo: bitmapInfo,
|
||||
colorSpace: colorSpace ?? CGColorSpaceCreateDeviceRGB(),
|
||||
bitsPerComponent: bitsPerComponent)
|
||||
let context = CGContext.create(width: ctxWidth,
|
||||
height: ctxHeight,
|
||||
bitmapInfo: bitmapInfo,
|
||||
colorSpace: colorSpace ?? CGColorSpaceCreateDeviceRGB(),
|
||||
bitsPerComponent: bitsPerComponent)
|
||||
|
||||
guard let ctx = context ?? CGContext(width: width, height: height) else {
|
||||
guard let ctx = context ?? CGContext.create(width: width, height: height) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -110,13 +110,13 @@ public extension CGImage {
|
|||
let ctxWidth = Int(ceil(newSize.width))
|
||||
let ctxHeight = Int(ceil(newSize.height))
|
||||
|
||||
let context = CGContext(width: ctxWidth,
|
||||
height: ctxHeight,
|
||||
bitmapInfo: bitmapInfo,
|
||||
colorSpace: colorSpace ?? CGColorSpaceCreateDeviceRGB(),
|
||||
bitsPerComponent: bitsPerComponent)
|
||||
let context = CGContext.create(width: ctxWidth,
|
||||
height: ctxHeight,
|
||||
bitmapInfo: bitmapInfo,
|
||||
colorSpace: colorSpace ?? CGColorSpaceCreateDeviceRGB(),
|
||||
bitsPerComponent: bitsPerComponent)
|
||||
|
||||
guard let ctx = context ?? CGContext(width: ctxWidth, height: ctxHeight) else {
|
||||
guard let ctx = context ?? CGContext.create(width: ctxWidth, height: ctxHeight) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -176,13 +176,13 @@ public extension CGImage {
|
|||
let ctxWidth = Int(ceil(CGFloat(width) + padding * 2))
|
||||
let ctxHeight = Int(ceil(CGFloat(height) + padding * 2))
|
||||
|
||||
let context = CGContext(width: ctxWidth,
|
||||
height: ctxHeight,
|
||||
bitmapInfo: bitmapInfo,
|
||||
colorSpace: colorSpace ?? CGColorSpaceCreateDeviceRGB(),
|
||||
bitsPerComponent: bitsPerComponent)
|
||||
let context = CGContext.create(width: ctxWidth,
|
||||
height: ctxHeight,
|
||||
bitmapInfo: bitmapInfo,
|
||||
colorSpace: colorSpace ?? CGColorSpaceCreateDeviceRGB(),
|
||||
bitsPerComponent: bitsPerComponent)
|
||||
|
||||
guard let ctx = context ?? CGContext(width: ctxWidth, height: ctxHeight) else {
|
||||
guard let ctx = context ?? CGContext.create(width: ctxWidth, height: ctxHeight) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@
|
|||
|
||||
import UIKit
|
||||
|
||||
extension UIDevice {
|
||||
public extension UIDevice {
|
||||
|
||||
/// Returns true if the current device is simulator
|
||||
open static var isSimulator: Bool {
|
||||
public static var isSimulator: Bool {
|
||||
return ProcessInfo.processInfo.environment["SIMULATOR_DEVICE_NAME"] != nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue