Skip to content

Commit

Permalink
Added NotchImageView
Browse files Browse the repository at this point in the history
  • Loading branch information
AFathi committed Nov 9, 2017
1 parent f78132e commit 263da3d
Show file tree
Hide file tree
Showing 21 changed files with 524 additions and 23 deletions.
22 changes: 21 additions & 1 deletion Example/NotchToolkit-Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
8B46D7347C51E13D6A8F5752 /* Pods_NotchToolkit_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EB89330EB9E75950CC5DD1E5 /* Pods_NotchToolkit_Example.framework */; };
9F0D407B72BC9454BFAE5029 /* Pods_NotchToolkit_ExampleTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F265AEF721C276AAF9FEFDF8 /* Pods_NotchToolkit_ExampleTests.framework */; };
FB211D911F7AE647008D87CE /* CornerOvalViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB211D901F7AE647008D87CE /* CornerOvalViewController.swift */; };
FB5F45721FB3DFA0004C542D /* NotchImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB5F45711FB3DFA0004C542D /* NotchImageView.swift */; };
FB5F45741FB3E029004C542D /* NotchImageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB5F45731FB3E029004C542D /* NotchImageViewController.swift */; };
FB5F45771FB3E178004C542D /* tst_img.JPG in Resources */ = {isa = PBXBuildFile; fileRef = FB5F45761FB3E178004C542D /* tst_img.JPG */; };
FBB4BF521F79ED69001992BA /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FBB4BF511F79ED69001992BA /* AppDelegate.swift */; };
FBB4BF541F79ED69001992BA /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FBB4BF531F79ED69001992BA /* ViewController.swift */; };
FBB4BF571F79ED69001992BA /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FBB4BF551F79ED69001992BA /* Main.storyboard */; };
Expand Down Expand Up @@ -75,6 +78,9 @@
F02A2878BAA2A5AB05FCF077 /* Pods-NotchToolkit-Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NotchToolkit-Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-NotchToolkit-Example/Pods-NotchToolkit-Example.debug.xcconfig"; sourceTree = "<group>"; };
F265AEF721C276AAF9FEFDF8 /* Pods_NotchToolkit_ExampleTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_NotchToolkit_ExampleTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
FB211D901F7AE647008D87CE /* CornerOvalViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CornerOvalViewController.swift; sourceTree = "<group>"; };
FB5F45711FB3DFA0004C542D /* NotchImageView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotchImageView.swift; sourceTree = "<group>"; };
FB5F45731FB3E029004C542D /* NotchImageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotchImageViewController.swift; sourceTree = "<group>"; };
FB5F45761FB3E178004C542D /* tst_img.JPG */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = tst_img.JPG; sourceTree = "<group>"; };
FBB4BF4E1F79ED69001992BA /* NotchToolkit-Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "NotchToolkit-Example.app"; sourceTree = BUILT_PRODUCTS_DIR; };
FBB4BF511F79ED69001992BA /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
FBB4BF531F79ED69001992BA /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -153,6 +159,15 @@
name = Pods;
sourceTree = "<group>";
};
FB5F45751FB3E164004C542D /* Assets */ = {
isa = PBXGroup;
children = (
FB5F45761FB3E178004C542D /* tst_img.JPG */,
FBB4BF581F79ED69001992BA /* Assets.xcassets */,
);
path = Assets;
sourceTree = "<group>";
};
FBB4BF451F79ED69001992BA = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -181,11 +196,12 @@
children = (
FBB4BF511F79ED69001992BA /* AppDelegate.swift */,
FBB4BF531F79ED69001992BA /* ViewController.swift */,
FB5F45731FB3E029004C542D /* NotchImageViewController.swift */,
FB211D901F7AE647008D87CE /* CornerOvalViewController.swift */,
FBB4BF551F79ED69001992BA /* Main.storyboard */,
FBB4BF581F79ED69001992BA /* Assets.xcassets */,
FBB4BF5A1F79ED69001992BA /* LaunchScreen.storyboard */,
FBB4BF5D1F79ED69001992BA /* Info.plist */,
FB5F45751FB3E164004C542D /* Assets */,
);
path = "NotchToolkit-Example";
sourceTree = "<group>";
Expand Down Expand Up @@ -226,6 +242,7 @@
isa = PBXGroup;
children = (
FBED19241FB0253400D810BF /* NotchBar.swift */,
FB5F45711FB3DFA0004C542D /* NotchImageView.swift */,
FBED19231FB0253400D810BF /* NotchToolbar.swift */,
);
path = Classes;
Expand Down Expand Up @@ -387,6 +404,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
FB5F45771FB3E178004C542D /* tst_img.JPG in Resources */,
FBB4BF5C1F79ED69001992BA /* LaunchScreen.storyboard in Resources */,
FBB4BF591F79ED69001992BA /* Assets.xcassets in Resources */,
FBB4BF571F79ED69001992BA /* Main.storyboard in Resources */,
Expand Down Expand Up @@ -520,6 +538,7 @@
FB211D911F7AE647008D87CE /* CornerOvalViewController.swift in Sources */,
FBB4BF541F79ED69001992BA /* ViewController.swift in Sources */,
FBB4BF521F79ED69001992BA /* AppDelegate.swift in Sources */,
FB5F45741FB3E029004C542D /* NotchImageViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -539,6 +558,7 @@
FBED193E1FB0257D00D810BF /* NotchToolNameIconCell.swift in Sources */,
FBED19361FB0256900D810BF /* DeviceOrientation.swift in Sources */,
FBED19371FB0256900D810BF /* NotchMode.swift in Sources */,
FB5F45721FB3DFA0004C542D /* NotchImageView.swift in Sources */,
FBED19381FB0256900D810BF /* NotchScroll.swift in Sources */,
FBED19391FB0256900D810BF /* ToolIconTypes.swift in Sources */,
FBED193A1FB0256900D810BF /* CurveSettings.swift in Sources */,
Expand Down
Binary file added Example/NotchToolkit-Example/Assets/tst_img.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 53 additions & 10 deletions Example/NotchToolkit-Example/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="NotchToolkit" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1ee-AF-GVa">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="NotchToolbar" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1ee-AF-GVa">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="26"/>
Expand All @@ -40,21 +40,64 @@
<segue destination="f5f-YO-Z9x" kind="show" id="WxB-G9-4ab"/>
</connections>
</button>
<imageView userInteractionEnabled="NO" alpha="0.0" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="t8o-PU-2kD">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</imageView>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="RvZ-0f-8yR">
<rect key="frame" x="45" y="529" width="285" height="63"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" heightSizable="YES"/>
<state key="normal" title="Go to Notch Image View"/>
<connections>
<segue destination="YtO-Tk-0Za" kind="show" id="EaV-9A-8es"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
<connections>
<outlet property="notchImage" destination="t8o-PU-2kD" id="KfB-2v-kL3"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="136.80000000000001" y="126.38680659670166"/>
<point key="canvasLocation" x="-305" y="126"/>
</scene>
<!--Notch Image View Controller-->
<scene sceneID="Ohz-rG-Qau">
<objects>
<viewController storyboardIdentifier="notchImage" useStoryboardIdentifierAsRestorationIdentifier="YES" id="YtO-Tk-0Za" customClass="NotchImageViewController" customModule="NotchToolkit_Example" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="ZI6-2h-NIf">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="NotchImageView" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="03q-4k-wet">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="26"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="gC6-2C-E9P">
<rect key="frame" x="16" y="97" width="343" height="50"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<state key="normal" title="back"/>
<connections>
<action selector="dismissView:" destination="f5f-YO-Z9x" eventType="touchUpInside" id="FtV-94-RTR"/>
<action selector="goBack:" destination="YtO-Tk-0Za" eventType="touchUpInside" id="tWF-aY-emt"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="eHE-6h-hcN">
<rect key="frame" x="45" y="421" width="285" height="63"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="0.5" colorSpace="custom" customColorSpace="sRGB"/>
<state key="normal" title="Load Image from Notch"/>
<connections>
<action selector="loadNotchImage:" destination="YtO-Tk-0Za" eventType="touchUpInside" id="jwi-Iw-MbM"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<viewLayoutGuide key="safeArea" id="Lg6-xk-yB0"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Ywk-8e-oQu" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-306" y="951"/>
</scene>
<!--Corner Oval View Controller-->
<scene sceneID="ZNT-76-vcG">
Expand Down Expand Up @@ -133,7 +176,7 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="yiy-Qs-tPx" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="783.20000000000005" y="126.38680659670166"/>
<point key="canvasLocation" x="486" y="125"/>
</scene>
</scenes>
</document>
66 changes: 66 additions & 0 deletions Example/NotchToolkit-Example/NotchImageViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//
// NotchImageViewController.swift
// NotchToolkit-Example
//
// Created by Ahmed Bekhit on 11/8/17.
// Copyright © 2017 Ahmed Fathi Bekhit. All rights reserved.
//

import UIKit
import NotchToolkit

// MARK: - Implement NotchToolkit

//Step 1. add `NotchToolbarDelegate`
//Step 2. implement delegate functions, check NotchToolkit Delegates

class NotchImageViewController: UIViewController {
//Step 3. initialize `NotchImageView`
var imageView: NotchImageView?

override func viewDidLoad() {
super.viewDidLoad()
imageView = NotchImageView(image: UIImage(named:"tst_img.JPG"))
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}

}

// MARK: - NotchToolkit Delegate Methods
extension NotchImageViewController: NotchToolbarDelegate {
func deviceDidRotate() {
//Step 5. call `autoResize` in the `deviceDidRotate` function
imageView?.autoResize()
}

// This delegate function allows you to detect which toolbar icon was selected.
func didTapToolIcon(_ tools: UICollectionView, toolIndex: IndexPath, section: Int, row: Int) {
}
}

// MARK: - ViewController Buttons IBAction
extension NotchImageViewController {
@IBAction func loadNotchImage(_ sender: UIButton) {
if !(imageView?.isVisible)! {
sender.setTitle("Delete Image Object", for: .normal)
imageView?.durationIntervals = 2.8
imageView?.printBarColor = .red
imageView?.printBarHeight = 5
imageView?.delegate = self
imageView?.prepare(in: self)
imageView?.load()
self.view.insertSubview(sender, aboveSubview: imageView!)
}else{
sender.setTitle("Load Image from Notch", for: .normal)
imageView?.remove()
imageView = NotchImageView(image: UIImage(named:"tst_img.JPG"))
}
}

@IBAction func goBack(_ sender: UIButton) {
self.dismiss(animated: true, completion: nil)
}
}
3 changes: 0 additions & 3 deletions Example/NotchToolkit-Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,12 @@ extension ViewController {
//Step 2. implement delegate functions, check NotchToolkit Delegates

class ViewController: UIViewController {
@IBOutlet var notchImage: UIImageView!

//Step 3. initialize `NotchToolbar`
let toolbar = NotchToolbar()
var imgView:UIImageView!

override func viewDidLoad() {
super.viewDidLoad()

//Step 4. setup `NotchToolbar` options

//Set to true to make the toolbar visible initially--default is false.
Expand Down
Loading

0 comments on commit 263da3d

Please sign in to comment.