-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
524 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
Example/NotchToolkit-Example/NotchImageViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.