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
6 changes: 3 additions & 3 deletions Example/Example/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
29 changes: 28 additions & 1 deletion iOSPhotoEditor/PhotoEditorViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,16 @@ public final class PhotoEditorViewController: UIViewController {
@IBOutlet weak var saveButton: UIButton!
@IBOutlet weak var shareButton: UIButton!
@IBOutlet weak var clearButton: UIButton!
@IBOutlet weak var continueButton: UIButton!

public var cropButtonImage: UIImage?
public var stickerButtonImage: UIImage?
public var drawButtonImage: UIImage?
public var textButtonImage: UIImage?
public var saveButtonImage: UIImage?
public var shareButtonImage: UIImage?
public var clearButtonImage: UIImage?
public var continueButtonImage: UIImage?
public var image: UIImage?
/**
Array of Stickers -UIImage- that the user will choose from
Expand Down Expand Up @@ -86,7 +95,7 @@ public final class PhotoEditorViewController: UIViewController {
deleteView.layer.borderWidth = 2.0
deleteView.layer.borderColor = UIColor.white.cgColor
deleteView.clipsToBounds = true

setCustomImages()
let edgePan = UIScreenEdgePanGestureRecognizer(target: self, action: #selector(screenEdgeSwiped))
edgePan.edges = .bottom
edgePan.delegate = self
Expand Down Expand Up @@ -137,6 +146,24 @@ public final class PhotoEditorViewController: UIViewController {
bottomToolbar.isHidden = hide
bottomGradient.isHidden = hide
}

func setCustomImages() {
setImage(cropButtonImage, forButton: cropButton)
setImage(stickerButtonImage, forButton: stickerButton)
setImage(drawButtonImage, forButton: drawButton)
setImage(textButtonImage, forButton: textButton)
setImage(saveButtonImage, forButton: saveButton)
setImage(shareButtonImage, forButton: shareButton)
setImage(clearButtonImage, forButton: clearButton)
setImage(continueButtonImage, forButton: continueButton)
}

func setImage(_ image: UIImage?, forButton button: UIButton) {
guard let image = image else { return }
button.setTitle(nil, for: .normal)
button.setImage(image, for: .normal)
button.tintColor = .white
}
}

extension PhotoEditorViewController: ColorDelegate {
Expand Down
49 changes: 26 additions & 23 deletions iOSPhotoEditor/PhotoEditorViewController.xib
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_5" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_5" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17125"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand All @@ -25,6 +23,7 @@
<outlet property="colorPickerView" destination="Cy8-ap-fH9" id="KJx-KY-rfM"/>
<outlet property="colorPickerViewBottomConstraint" destination="mok-x4-xHA" id="SKq-N5-bcn"/>
<outlet property="colorsCollectionView" destination="GaQ-XR-asZ" id="1rf-hU-0nn"/>
<outlet property="continueButton" destination="wNH-TU-KxG" id="U42-gu-gts"/>
<outlet property="cropButton" destination="Ghm-bq-BmY" id="f2D-02-o1D"/>
<outlet property="deleteView" destination="yAt-sK-1nK" id="0Jn-1A-WAT"/>
<outlet property="doneButton" destination="KxU-y4-Jwh" id="19z-FV-eWC"/>
Expand Down Expand Up @@ -83,10 +82,10 @@
<rect key="frame" x="0.0" y="44" width="414" height="60"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="15" translatesAutoresizingMaskIntoConstraints="NO" id="Doi-2Z-r5q">
<rect key="frame" x="237" y="0.0" width="165" height="60"/>
<rect key="frame" x="237" y="20" width="165" height="20"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Ghm-bq-BmY">
<rect key="frame" x="0.0" y="0.0" width="30" height="60"/>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Ghm-bq-BmY">
<rect key="frame" x="0.0" y="0.0" width="30" height="20"/>
<fontDescription key="fontDescription" name="icomoon" family="icomoon" pointSize="25"/>
<size key="titleShadowOffset" width="1" height="0.0"/>
<state key="normal" title="">
Expand All @@ -97,8 +96,8 @@
<action selector="cropButtonTapped:" destination="-1" eventType="touchUpInside" id="fa9-jd-guk"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="PLX-iy-2Rc">
<rect key="frame" x="45" y="0.0" width="30" height="60"/>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="PLX-iy-2Rc">
<rect key="frame" x="45" y="0.0" width="30" height="20"/>
<fontDescription key="fontDescription" name="icomoon" family="icomoon" pointSize="25"/>
<size key="titleShadowOffset" width="1" height="0.0"/>
<state key="normal" title="">
Expand All @@ -109,8 +108,8 @@
<action selector="stickersButtonTapped:" destination="-1" eventType="touchUpInside" id="snI-Px-Ngx"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Qm4-f6-DBr">
<rect key="frame" x="90" y="0.0" width="30" height="60"/>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Qm4-f6-DBr">
<rect key="frame" x="90" y="0.0" width="30" height="20"/>
<fontDescription key="fontDescription" name="icomoon" family="icomoon" pointSize="25"/>
<size key="titleShadowOffset" width="1" height="0.0"/>
<state key="normal" title="">
Expand All @@ -121,8 +120,8 @@
<action selector="drawButtonTapped:" destination="-1" eventType="touchUpInside" id="uts-mM-XHI"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="0wH-LJ-SyD">
<rect key="frame" x="135" y="0.0" width="30" height="60"/>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="0wH-LJ-SyD">
<rect key="frame" x="135" y="0.0" width="30" height="20"/>
<fontDescription key="fontDescription" name="icomoon" family="icomoon" pointSize="25"/>
<size key="titleShadowOffset" width="1" height="0.0"/>
<state key="normal" title="">
Expand All @@ -134,8 +133,12 @@
</connections>
</button>
</subviews>
<constraints>
<constraint firstAttribute="height" constant="20" id="awC-Q9-ApR"/>
<constraint firstAttribute="width" constant="165" id="rvh-Qc-ANN"/>
</constraints>
</stackView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="9an-1W-thw">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="9an-1W-thw">
<rect key="frame" x="12" y="11.666666666666664" width="30" height="37"/>
<fontDescription key="fontDescription" name="icomoon" family="icomoon" pointSize="25"/>
<size key="titleShadowOffset" width="1" height="0.0"/>
Expand All @@ -151,11 +154,11 @@
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="9an-1W-thw" firstAttribute="centerY" secondItem="3MS-N5-3xY" secondAttribute="centerY" id="1bY-xX-lhc"/>
<constraint firstAttribute="bottom" secondItem="Doi-2Z-r5q" secondAttribute="bottom" id="5UH-pm-VlP"/>
<constraint firstItem="9an-1W-thw" firstAttribute="centerY" secondItem="Doi-2Z-r5q" secondAttribute="centerY" id="8qQ-Nl-YtZ"/>
<constraint firstAttribute="trailing" secondItem="Doi-2Z-r5q" secondAttribute="trailing" constant="12" id="Ank-Rs-hHo"/>
<constraint firstAttribute="height" constant="60" id="RSV-Dw-76F"/>
<constraint firstItem="Doi-2Z-r5q" firstAttribute="top" secondItem="3MS-N5-3xY" secondAttribute="top" id="YMJ-5J-baj"/>
<constraint firstItem="9an-1W-thw" firstAttribute="leading" secondItem="3MS-N5-3xY" secondAttribute="leading" constant="12" id="lPL-cU-BVr"/>
<constraint firstItem="Doi-2Z-r5q" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="9an-1W-thw" secondAttribute="trailing" constant="16" id="mpz-62-9n4"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ZGa-1B-gkO" customClass="GradientView" customModule="iOSPhotoEditor" customModuleProvider="target">
Expand All @@ -174,7 +177,7 @@
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="15" translatesAutoresizingMaskIntoConstraints="NO" id="ZRl-89-gRO">
<rect key="frame" x="12" y="0.0" width="120" height="52"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="mW4-Jz-sic">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="mW4-Jz-sic">
<rect key="frame" x="0.0" y="0.0" width="30" height="52"/>
<fontDescription key="fontDescription" name="icomoon" family="icomoon" pointSize="25"/>
<size key="titleShadowOffset" width="1" height="0.0"/>
Expand All @@ -186,7 +189,7 @@
<action selector="saveButtonTapped:" destination="-1" eventType="touchUpInside" id="Sc7-Zy-r4v"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="zlw-H0-WcJ">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="zlw-H0-WcJ">
<rect key="frame" x="45" y="0.0" width="30" height="52"/>
<fontDescription key="fontDescription" name="icomoon" family="icomoon" pointSize="25"/>
<size key="titleShadowOffset" width="1" height="0.0"/>
Expand All @@ -198,7 +201,7 @@
<action selector="shareButtonTapped:" destination="-1" eventType="touchUpInside" id="ZTG-wV-jfh"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Kpe-Ez-Cio">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Kpe-Ez-Cio">
<rect key="frame" x="90" y="0.0" width="30" height="52"/>
<fontDescription key="fontDescription" name="icomoon" family="icomoon" pointSize="25"/>
<size key="titleShadowOffset" width="1" height="0.0"/>
Expand All @@ -212,7 +215,7 @@
</button>
</subviews>
</stackView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="wNH-TU-KxG">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="wNH-TU-KxG">
<rect key="frame" x="352" y="-14" width="50" height="62"/>
<fontDescription key="fontDescription" name="icomoon" family="icomoon" pointSize="50"/>
<size key="titleShadowOffset" width="1" height="0.0"/>
Expand All @@ -235,7 +238,7 @@
<constraint firstItem="ZRl-89-gRO" firstAttribute="leading" secondItem="87h-1G-t5q" secondAttribute="leading" constant="12" id="mn5-Hu-M5A"/>
</constraints>
</view>
<button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="KxU-y4-Jwh">
<button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="KxU-y4-Jwh">
<rect key="frame" x="362" y="60" width="40" height="32"/>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="16"/>
<size key="titleShadowOffset" width="1" height="0.0"/>
Expand Down Expand Up @@ -294,6 +297,7 @@
</constraints>
</view>
</subviews>
<viewLayoutGuide key="safeArea" id="ymm-th-TTo"/>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="87h-1G-t5q" firstAttribute="leading" secondItem="HPk-Bg-V0q" secondAttribute="leading" id="0ft-JY-szV"/>
Expand Down Expand Up @@ -321,7 +325,6 @@
<constraint firstItem="S1Y-ZS-dct" firstAttribute="centerX" secondItem="HPk-Bg-V0q" secondAttribute="centerX" id="uyk-kx-vrC"/>
<constraint firstItem="3MS-N5-3xY" firstAttribute="leading" secondItem="HPk-Bg-V0q" secondAttribute="leading" id="zYw-cX-ezI"/>
</constraints>
<viewLayoutGuide key="safeArea" id="ymm-th-TTo"/>
<point key="canvasLocation" x="137.68115942028987" y="153.34821428571428"/>
</view>
</objects>
Expand Down