Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

* add support custom CIContextFactory.use it fix crash in iOS8 #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion QRCode/CIImageExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ internal extension CIImage {
///
/// - returns: an non-interpolated UIImage
internal func nonInterpolatedImage(withScale scale: Scale = Scale(dx: 1, dy: 1)) -> UIImage? {
guard let cgImage = CIContext(options: nil).createCGImage(self, from: self.extent) else { return nil }
var ciContext:CIContext?
if QRCode.CIContextFactory != nil {
ciContext = QRCode.CIContextFactory!()
}else{
ciContext = CIContext(options: nil)
}
guard let cgImage = ciContext?.createCGImage(self, from: self.extent) else { return nil }
let size = CGSize(width: self.extent.size.width * scale.dx, height: self.extent.size.height * scale.dy)

UIGraphicsBeginImageContextWithOptions(size, true, 0)
Expand Down
2 changes: 2 additions & 0 deletions QRCode/QRCode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public typealias 🔳 = QRCode
/// QRCode generator
public struct QRCode {

public static var CIContextFactory:(()->CIContext)?

/**
The level of error correction.

Expand Down