Skip to content

Commit 263da3d

Browse files
committed
Added NotchImageView
1 parent f78132e commit 263da3d

File tree

21 files changed

+524
-23
lines changed

21 files changed

+524
-23
lines changed

Example/NotchToolkit-Example.xcodeproj/project.pbxproj

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
8B46D7347C51E13D6A8F5752 /* Pods_NotchToolkit_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EB89330EB9E75950CC5DD1E5 /* Pods_NotchToolkit_Example.framework */; };
1111
9F0D407B72BC9454BFAE5029 /* Pods_NotchToolkit_ExampleTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F265AEF721C276AAF9FEFDF8 /* Pods_NotchToolkit_ExampleTests.framework */; };
1212
FB211D911F7AE647008D87CE /* CornerOvalViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB211D901F7AE647008D87CE /* CornerOvalViewController.swift */; };
13+
FB5F45721FB3DFA0004C542D /* NotchImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB5F45711FB3DFA0004C542D /* NotchImageView.swift */; };
14+
FB5F45741FB3E029004C542D /* NotchImageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB5F45731FB3E029004C542D /* NotchImageViewController.swift */; };
15+
FB5F45771FB3E178004C542D /* tst_img.JPG in Resources */ = {isa = PBXBuildFile; fileRef = FB5F45761FB3E178004C542D /* tst_img.JPG */; };
1316
FBB4BF521F79ED69001992BA /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FBB4BF511F79ED69001992BA /* AppDelegate.swift */; };
1417
FBB4BF541F79ED69001992BA /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FBB4BF531F79ED69001992BA /* ViewController.swift */; };
1518
FBB4BF571F79ED69001992BA /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FBB4BF551F79ED69001992BA /* Main.storyboard */; };
@@ -75,6 +78,9 @@
7578
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>"; };
7679
F265AEF721C276AAF9FEFDF8 /* Pods_NotchToolkit_ExampleTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_NotchToolkit_ExampleTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
7780
FB211D901F7AE647008D87CE /* CornerOvalViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CornerOvalViewController.swift; sourceTree = "<group>"; };
81+
FB5F45711FB3DFA0004C542D /* NotchImageView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotchImageView.swift; sourceTree = "<group>"; };
82+
FB5F45731FB3E029004C542D /* NotchImageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotchImageViewController.swift; sourceTree = "<group>"; };
83+
FB5F45761FB3E178004C542D /* tst_img.JPG */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = tst_img.JPG; sourceTree = "<group>"; };
7884
FBB4BF4E1F79ED69001992BA /* NotchToolkit-Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "NotchToolkit-Example.app"; sourceTree = BUILT_PRODUCTS_DIR; };
7985
FBB4BF511F79ED69001992BA /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
8086
FBB4BF531F79ED69001992BA /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
@@ -153,6 +159,15 @@
153159
name = Pods;
154160
sourceTree = "<group>";
155161
};
162+
FB5F45751FB3E164004C542D /* Assets */ = {
163+
isa = PBXGroup;
164+
children = (
165+
FB5F45761FB3E178004C542D /* tst_img.JPG */,
166+
FBB4BF581F79ED69001992BA /* Assets.xcassets */,
167+
);
168+
path = Assets;
169+
sourceTree = "<group>";
170+
};
156171
FBB4BF451F79ED69001992BA = {
157172
isa = PBXGroup;
158173
children = (
@@ -181,11 +196,12 @@
181196
children = (
182197
FBB4BF511F79ED69001992BA /* AppDelegate.swift */,
183198
FBB4BF531F79ED69001992BA /* ViewController.swift */,
199+
FB5F45731FB3E029004C542D /* NotchImageViewController.swift */,
184200
FB211D901F7AE647008D87CE /* CornerOvalViewController.swift */,
185201
FBB4BF551F79ED69001992BA /* Main.storyboard */,
186-
FBB4BF581F79ED69001992BA /* Assets.xcassets */,
187202
FBB4BF5A1F79ED69001992BA /* LaunchScreen.storyboard */,
188203
FBB4BF5D1F79ED69001992BA /* Info.plist */,
204+
FB5F45751FB3E164004C542D /* Assets */,
189205
);
190206
path = "NotchToolkit-Example";
191207
sourceTree = "<group>";
@@ -226,6 +242,7 @@
226242
isa = PBXGroup;
227243
children = (
228244
FBED19241FB0253400D810BF /* NotchBar.swift */,
245+
FB5F45711FB3DFA0004C542D /* NotchImageView.swift */,
229246
FBED19231FB0253400D810BF /* NotchToolbar.swift */,
230247
);
231248
path = Classes;
@@ -387,6 +404,7 @@
387404
isa = PBXResourcesBuildPhase;
388405
buildActionMask = 2147483647;
389406
files = (
407+
FB5F45771FB3E178004C542D /* tst_img.JPG in Resources */,
390408
FBB4BF5C1F79ED69001992BA /* LaunchScreen.storyboard in Resources */,
391409
FBB4BF591F79ED69001992BA /* Assets.xcassets in Resources */,
392410
FBB4BF571F79ED69001992BA /* Main.storyboard in Resources */,
@@ -520,6 +538,7 @@
520538
FB211D911F7AE647008D87CE /* CornerOvalViewController.swift in Sources */,
521539
FBB4BF541F79ED69001992BA /* ViewController.swift in Sources */,
522540
FBB4BF521F79ED69001992BA /* AppDelegate.swift in Sources */,
541+
FB5F45741FB3E029004C542D /* NotchImageViewController.swift in Sources */,
523542
);
524543
runOnlyForDeploymentPostprocessing = 0;
525544
};
@@ -539,6 +558,7 @@
539558
FBED193E1FB0257D00D810BF /* NotchToolNameIconCell.swift in Sources */,
540559
FBED19361FB0256900D810BF /* DeviceOrientation.swift in Sources */,
541560
FBED19371FB0256900D810BF /* NotchMode.swift in Sources */,
561+
FB5F45721FB3DFA0004C542D /* NotchImageView.swift in Sources */,
542562
FBED19381FB0256900D810BF /* NotchScroll.swift in Sources */,
543563
FBED19391FB0256900D810BF /* ToolIconTypes.swift in Sources */,
544564
FBED193A1FB0256900D810BF /* CurveSettings.swift in Sources */,

Example/NotchToolkit-Example/Assets.xcassets/AppIcon.appiconset/Contents.json renamed to Example/NotchToolkit-Example/Assets/Assets.xcassets/AppIcon.appiconset/Contents.json

File renamed without changes.

Example/NotchToolkit-Example/Assets.xcassets/Contents.json renamed to Example/NotchToolkit-Example/Assets/Assets.xcassets/Contents.json

File renamed without changes.

Example/NotchToolkit-Example/Assets.xcassets/pikachusquare.imageset/Contents.json renamed to Example/NotchToolkit-Example/Assets/Assets.xcassets/pikachusquare.imageset/Contents.json

File renamed without changes.

Example/NotchToolkit-Example/Assets.xcassets/pikachusquare.imageset/pikachusquare.png renamed to Example/NotchToolkit-Example/Assets/Assets.xcassets/pikachusquare.imageset/pikachusquare.png

File renamed without changes.

Example/NotchToolkit-Example/Assets.xcassets/spongebob.imageset/Contents.json renamed to Example/NotchToolkit-Example/Assets/Assets.xcassets/spongebob.imageset/Contents.json

File renamed without changes.

Example/NotchToolkit-Example/Assets.xcassets/spongebob.imageset/spongebob.png renamed to Example/NotchToolkit-Example/Assets/Assets.xcassets/spongebob.imageset/spongebob.png

File renamed without changes.
734 KB
Loading

Example/NotchToolkit-Example/Base.lproj/Main.storyboard

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
1818
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
1919
<subviews>
20-
<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">
20+
<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">
2121
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
2222
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
2323
<fontDescription key="fontDescription" type="system" pointSize="26"/>
@@ -40,21 +40,64 @@
4040
<segue destination="f5f-YO-Z9x" kind="show" id="WxB-G9-4ab"/>
4141
</connections>
4242
</button>
43-
<imageView userInteractionEnabled="NO" alpha="0.0" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="t8o-PU-2kD">
44-
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
45-
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
46-
</imageView>
43+
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="RvZ-0f-8yR">
44+
<rect key="frame" x="45" y="529" width="285" height="63"/>
45+
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" heightSizable="YES"/>
46+
<state key="normal" title="Go to Notch Image View"/>
47+
<connections>
48+
<segue destination="YtO-Tk-0Za" kind="show" id="EaV-9A-8es"/>
49+
</connections>
50+
</button>
4751
</subviews>
4852
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
4953
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
5054
</view>
51-
<connections>
52-
<outlet property="notchImage" destination="t8o-PU-2kD" id="KfB-2v-kL3"/>
53-
</connections>
5455
</viewController>
5556
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
5657
</objects>
57-
<point key="canvasLocation" x="136.80000000000001" y="126.38680659670166"/>
58+
<point key="canvasLocation" x="-305" y="126"/>
59+
</scene>
60+
<!--Notch Image View Controller-->
61+
<scene sceneID="Ohz-rG-Qau">
62+
<objects>
63+
<viewController storyboardIdentifier="notchImage" useStoryboardIdentifierAsRestorationIdentifier="YES" id="YtO-Tk-0Za" customClass="NotchImageViewController" customModule="NotchToolkit_Example" customModuleProvider="target" sceneMemberID="viewController">
64+
<view key="view" contentMode="scaleToFill" id="ZI6-2h-NIf">
65+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
66+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
67+
<subviews>
68+
<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">
69+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
70+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
71+
<fontDescription key="fontDescription" type="system" pointSize="26"/>
72+
<nil key="textColor"/>
73+
<nil key="highlightedColor"/>
74+
</label>
75+
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="gC6-2C-E9P">
76+
<rect key="frame" x="16" y="97" width="343" height="50"/>
77+
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
78+
<state key="normal" title="back"/>
79+
<connections>
80+
<action selector="dismissView:" destination="f5f-YO-Z9x" eventType="touchUpInside" id="FtV-94-RTR"/>
81+
<action selector="goBack:" destination="YtO-Tk-0Za" eventType="touchUpInside" id="tWF-aY-emt"/>
82+
</connections>
83+
</button>
84+
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="eHE-6h-hcN">
85+
<rect key="frame" x="45" y="421" width="285" height="63"/>
86+
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" heightSizable="YES"/>
87+
<color key="backgroundColor" red="1" green="1" blue="1" alpha="0.5" colorSpace="custom" customColorSpace="sRGB"/>
88+
<state key="normal" title="Load Image from Notch"/>
89+
<connections>
90+
<action selector="loadNotchImage:" destination="YtO-Tk-0Za" eventType="touchUpInside" id="jwi-Iw-MbM"/>
91+
</connections>
92+
</button>
93+
</subviews>
94+
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
95+
<viewLayoutGuide key="safeArea" id="Lg6-xk-yB0"/>
96+
</view>
97+
</viewController>
98+
<placeholder placeholderIdentifier="IBFirstResponder" id="Ywk-8e-oQu" userLabel="First Responder" sceneMemberID="firstResponder"/>
99+
</objects>
100+
<point key="canvasLocation" x="-306" y="951"/>
58101
</scene>
59102
<!--Corner Oval View Controller-->
60103
<scene sceneID="ZNT-76-vcG">
@@ -133,7 +176,7 @@
133176
</viewController>
134177
<placeholder placeholderIdentifier="IBFirstResponder" id="yiy-Qs-tPx" userLabel="First Responder" sceneMemberID="firstResponder"/>
135178
</objects>
136-
<point key="canvasLocation" x="783.20000000000005" y="126.38680659670166"/>
179+
<point key="canvasLocation" x="486" y="125"/>
137180
</scene>
138181
</scenes>
139182
</document>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
//
2+
// NotchImageViewController.swift
3+
// NotchToolkit-Example
4+
//
5+
// Created by Ahmed Bekhit on 11/8/17.
6+
// Copyright © 2017 Ahmed Fathi Bekhit. All rights reserved.
7+
//
8+
9+
import UIKit
10+
import NotchToolkit
11+
12+
// MARK: - Implement NotchToolkit
13+
14+
//Step 1. add `NotchToolbarDelegate`
15+
//Step 2. implement delegate functions, check NotchToolkit Delegates
16+
17+
class NotchImageViewController: UIViewController {
18+
//Step 3. initialize `NotchImageView`
19+
var imageView: NotchImageView?
20+
21+
override func viewDidLoad() {
22+
super.viewDidLoad()
23+
imageView = NotchImageView(image: UIImage(named:"tst_img.JPG"))
24+
}
25+
26+
override func didReceiveMemoryWarning() {
27+
super.didReceiveMemoryWarning()
28+
}
29+
30+
}
31+
32+
// MARK: - NotchToolkit Delegate Methods
33+
extension NotchImageViewController: NotchToolbarDelegate {
34+
func deviceDidRotate() {
35+
//Step 5. call `autoResize` in the `deviceDidRotate` function
36+
imageView?.autoResize()
37+
}
38+
39+
// This delegate function allows you to detect which toolbar icon was selected.
40+
func didTapToolIcon(_ tools: UICollectionView, toolIndex: IndexPath, section: Int, row: Int) {
41+
}
42+
}
43+
44+
// MARK: - ViewController Buttons IBAction
45+
extension NotchImageViewController {
46+
@IBAction func loadNotchImage(_ sender: UIButton) {
47+
if !(imageView?.isVisible)! {
48+
sender.setTitle("Delete Image Object", for: .normal)
49+
imageView?.durationIntervals = 2.8
50+
imageView?.printBarColor = .red
51+
imageView?.printBarHeight = 5
52+
imageView?.delegate = self
53+
imageView?.prepare(in: self)
54+
imageView?.load()
55+
self.view.insertSubview(sender, aboveSubview: imageView!)
56+
}else{
57+
sender.setTitle("Load Image from Notch", for: .normal)
58+
imageView?.remove()
59+
imageView = NotchImageView(image: UIImage(named:"tst_img.JPG"))
60+
}
61+
}
62+
63+
@IBAction func goBack(_ sender: UIButton) {
64+
self.dismiss(animated: true, completion: nil)
65+
}
66+
}

0 commit comments

Comments
 (0)