Skip to content
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
4 changes: 4 additions & 0 deletions Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
0702A7461E80ABB90077B944 /* UIImageExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0702A7451E80ABB90077B944 /* UIImageExtension.swift */; };
4D248F0D1A751C3700E44E6B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D248F0C1A751C3700E44E6B /* AppDelegate.swift */; };
4D248F0F1A751C3700E44E6B /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D248F0E1A751C3700E44E6B /* ViewController.swift */; };
4D248F121A751C3700E44E6B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4D248F101A751C3700E44E6B /* Main.storyboard */; };
Expand Down Expand Up @@ -62,6 +63,7 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
0702A7451E80ABB90077B944 /* UIImageExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIImageExtension.swift; sourceTree = "<group>"; };
4D248F071A751C3700E44E6B /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
4D248F0B1A751C3700E44E6B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
4D248F0C1A751C3700E44E6B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -157,6 +159,7 @@
4D9240651A7805310069D66D /* CIColorExtension.swift */,
AA24AF3D1C247A7C00D1BEC7 /* CIImageExtension.swift */,
4D248F351A751C7800E44E6B /* QRCode.h */,
0702A7451E80ABB90077B944 /* UIImageExtension.swift */,
4D248F331A751C7800E44E6B /* Supporting Files */,
);
path = QRCode;
Expand Down Expand Up @@ -347,6 +350,7 @@
4D9240641A78050C0069D66D /* UIImageViewExtension.swift in Sources */,
4D248F521A751CE300E44E6B /* QRCode.swift in Sources */,
AA24AF3E1C247A7C00D1BEC7 /* CIImageExtension.swift in Sources */,
0702A7461E80ABB90077B944 /* UIImageExtension.swift in Sources */,
4D9240661A7805310069D66D /* CIColorExtension.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
58 changes: 48 additions & 10 deletions Example/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6724" systemVersion="14B25" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="vXZ-lx-hvc">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="vXZ-lx-hvc">
<device id="retina5_5" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6711"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
Expand All @@ -13,14 +18,14 @@
<viewControllerLayoutGuide type="bottom" id="2fi-mo-0CV"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="kh9-bI-dsS">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="jd7-dt-8LC">
<rect key="frame" x="132.5" y="188.5" width="335" height="222"/>
<rect key="frame" x="39.666666666666657" y="257" width="335" height="222"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="ldq-nY-0QF">
<rect key="frame" x="0.0" y="0.0" width="222" height="222"/>
<rect key="frame" x="0.0" y="0.0" width="222.00000000000003" height="222"/>
<constraints>
<constraint firstAttribute="width" constant="200" id="9jy-Mn-nqj"/>
<constraint firstAttribute="height" constant="200" id="UnJ-fd-fo5"/>
Expand All @@ -35,7 +40,7 @@
</variation>
</imageView>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="x8h-b6-iSb">
<rect key="frame" x="227" y="58" width="50" height="50"/>
<rect key="frame" x="227.00000000000003" y="58" width="49.999999999999972" height="50"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="VSN-bQ-vav"/>
<constraint firstAttribute="width" constant="50" id="woq-CJ-Nmx"/>
Expand All @@ -49,7 +54,7 @@
</constraints>
</imageView>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="q6v-7g-Eef">
<rect key="frame" x="227" y="0.0" width="50" height="50"/>
<rect key="frame" x="227.00000000000003" y="0.0" width="49.999999999999972" height="50"/>
<constraints>
<constraint firstAttribute="width" constant="50" id="Ycs-Ue-ddL"/>
<constraint firstAttribute="height" constant="50" id="hb4-G8-UGn"/>
Expand All @@ -70,7 +75,7 @@
</constraints>
</imageView>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="J50-ki-XSt" firstAttribute="top" secondItem="jd7-dt-8LC" secondAttribute="top" id="5m3-vz-bN6"/>
<constraint firstItem="MJh-3G-Vw5" firstAttribute="top" secondItem="x8h-b6-iSb" secondAttribute="bottom" constant="6" id="9TR-oX-Azl"/>
Expand All @@ -91,11 +96,43 @@
<constraint firstAttribute="bottom" secondItem="MJh-3G-Vw5" secondAttribute="bottom" id="ys6-NE-jIV"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="KhV-M4-O1s">
<rect key="frame" x="39.666666666666657" y="487" width="335" height="52"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Show Overlays" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sPA-VZ-RLi">
<rect key="frame" x="8" y="16" width="113" height="20"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="7ow-dO-cQx">
<rect key="frame" x="129" y="11.666666666666686" width="62" height="29.999999999999943"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="ljN-7O-q7P"/>
<constraint firstAttribute="width" constant="60" id="oqD-Q9-f6G"/>
</constraints>
<connections>
<action selector="showOverlaySwitched:" destination="vXZ-lx-hvc" eventType="valueChanged" id="HnE-Sf-tQL"/>
</connections>
</switch>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="52" id="1OA-6i-2Fh"/>
<constraint firstItem="sPA-VZ-RLi" firstAttribute="centerY" secondItem="KhV-M4-O1s" secondAttribute="centerY" id="4yG-EI-vMa"/>
<constraint firstItem="sPA-VZ-RLi" firstAttribute="leading" secondItem="KhV-M4-O1s" secondAttribute="leading" constant="8" id="kX3-rS-01a"/>
<constraint firstItem="7ow-dO-cQx" firstAttribute="leading" secondItem="sPA-VZ-RLi" secondAttribute="trailing" constant="8" id="ndh-aU-daJ"/>
<constraint firstItem="7ow-dO-cQx" firstAttribute="centerY" secondItem="KhV-M4-O1s" secondAttribute="centerY" id="ytI-f0-LgB"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" red="0.94117647058823528" green="0.94117647058823528" blue="0.94117647058823528" alpha="1" colorSpace="calibratedRGB"/>
<color key="backgroundColor" red="0.94117647058823528" green="0.94117647058823528" blue="0.94117647058823528" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="centerX" secondItem="jd7-dt-8LC" secondAttribute="centerX" id="7jy-z8-Tvk"/>
<constraint firstItem="KhV-M4-O1s" firstAttribute="top" secondItem="jd7-dt-8LC" secondAttribute="bottom" constant="8" id="8wI-Uy-qWb"/>
<constraint firstItem="KhV-M4-O1s" firstAttribute="centerX" secondItem="jd7-dt-8LC" secondAttribute="centerX" id="MvM-4Y-pH1"/>
<constraint firstAttribute="centerY" secondItem="jd7-dt-8LC" secondAttribute="centerY" id="mhm-cD-MLB"/>
<constraint firstItem="KhV-M4-O1s" firstAttribute="width" secondItem="jd7-dt-8LC" secondAttribute="width" id="uap-eq-SRL"/>
</constraints>
</view>
<connections>
Expand All @@ -109,6 +146,7 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="137" y="138"/>
</scene>
</scenes>
</document>
10 changes: 10 additions & 0 deletions Example/Images.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
Expand Down
6 changes: 6 additions & 0 deletions Example/Images.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
6 changes: 6 additions & 0 deletions Example/Images.xcassets/Overlays/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "address-card.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "address-card@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "address-card@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "street-view.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "street-view@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "street-view@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions Example/Images.xcassets/Overlays/thumbs-up.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "thumbs-up.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "thumbs-up@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "thumbs-up@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
99 changes: 94 additions & 5 deletions Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,24 @@ class ViewController: UIViewController {
@IBOutlet weak var imageViewSmall4: UIImageView!
@IBOutlet weak var imageViewMedium: UIImageView!
@IBOutlet weak var imageViewLarge: UIImageView!


override func viewDidLoad() {
super.viewDidLoad()


// We begin with codes with no overlay
showCodes()

}

@IBAction func showOverlaySwitched(_ sender: UISwitch) {
if sender.isOn {
showCodesWithOverlays()
} else {
showCodes()
}
}

func showCodes() {
// large
// default
imageViewLarge.image = {
Expand Down Expand Up @@ -68,8 +81,8 @@ class ViewController: UIViewController {
qrCode.color = CIColor(rgba: "c0392b")
qrCode.backgroundColor = CIColor(rgba: "f1c40f")
return qrCode.image
}()

}()

// small
// blue
Expand All @@ -79,7 +92,83 @@ class ViewController: UIViewController {
qrCode.color = CIColor(rgba: "2980b9")
return qrCode.image
}()

}

func showCodesWithOverlays() {
// large
// default
imageViewLarge.image = {
var qrCode = QRCode("http://github.com/aschuch/QRCode")!
qrCode.size = self.imageViewLarge.bounds.size
qrCode.errorCorrection = .High
qrCode.overlayImage = UIImage(named: "address-card")
qrCode.overlayImagePercentage = 0.75
return qrCode.imageWithOverlay
}()

// medium
// purple
imageViewMedium.image = {
var qrCode = QRCode("http://schuch.me")!
qrCode.size = self.imageViewMedium.bounds.size
qrCode.errorCorrection = .High
qrCode.color = CIColor(rgba: "8e44ad")
qrCode.overlayImage = UIImage(named: "street-view")
qrCode.overlayImagePercentage = 0.75
return qrCode.imageWithOverlay
}()

// small
// red (inverted)
imageViewSmall1.image = {
var qrCode = QRCode("http://objc.at")!
qrCode.size = self.imageViewSmall1.bounds.size
qrCode.errorCorrection = .High
qrCode.color = CIColor(rgba: "fff")
qrCode.backgroundColor = CIColor(rgba: "e74c3c")
qrCode.overlayImage = UIImage(named: "thumbs-up")
qrCode.overlayImagePercentage = 0.5
return qrCode.imageWithOverlay
}()

// small
// green
imageViewSmall2.image = {
var qrCode = QRCode("http://apple.com")!
qrCode.size = self.imageViewSmall1.bounds.size
qrCode.errorCorrection = .High
qrCode.color = CIColor(rgba: "16a085")
qrCode.backgroundColor = CIColor(rgba: "000")
qrCode.overlayImage = UIImage(named: "address-card")
qrCode.overlayImagePercentage = 0.5
return qrCode.imageWithOverlay
}()

// small
// orange
imageViewSmall3.image = {
var qrCode = QRCode("http://example.com")!
qrCode.size = self.imageViewSmall1.bounds.size
qrCode.errorCorrection = .High
qrCode.color = CIColor(rgba: "c0392b")
qrCode.backgroundColor = CIColor(rgba: "f1c40f")
qrCode.overlayImage = UIImage(named: "street-view")
qrCode.overlayImagePercentage = 0.5
return qrCode.imageWithOverlay
}()


// small
// blue
imageViewSmall4.image = {
var qrCode = QRCode("http://example.com")!
qrCode.size = self.imageViewSmall1.bounds.size
qrCode.errorCorrection = .High
qrCode.color = CIColor(rgba: "2980b9")
qrCode.overlayImage = UIImage(named: "thumbs-up")
qrCode.overlayImagePercentage = 0.5
return qrCode.imageWithOverlay
}()
}

}
2 changes: 1 addition & 1 deletion QRCode.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ Pod::Spec.new do |s|
s.platform = :ios, "8.0"
s.source = { :git => "https://github.com/aschuch/QRCode.git", :tag => s.version }
s.requires_arc = true
s.source_files = "QRCode/QRCode.swift", "QRCode/UIImageViewExtension.swift", "QRCode/CIColorExtension.swift", "QRCode/CIImageExtension.swift"
s.source_files = "QRCode/QRCode.swift", "QRCode/UIImageViewExtension.swift", "QRCode/CIColorExtension.swift", "QRCode/CIImageExtension.swift", "QRCode/UIImageExtension.swift"
end
Loading