-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from lekshmiraveendranath/allowFullscreen
Allow fullscreen Spotlights
- Loading branch information
Showing
14 changed files
with
119 additions
and
94 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
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
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
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
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
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
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
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
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
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,52 @@ | ||
// | ||
// SpotlightNode.swift | ||
// Spotlight | ||
// | ||
// Created by Lekshmi Raveendranathapanicker on 2/21/18. | ||
// Copyright © 2018 Lekshmi Raveendranathapanicker. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public enum SpotlightTarget { | ||
|
||
case view(UIView) | ||
case barButton(UIBarButtonItem) | ||
case tabBarItem(UITabBarController, Int) | ||
case point(CGPoint, radius: CGFloat) | ||
case rect(CGRect) | ||
|
||
var targetView: UIView { | ||
let target: UIView | ||
switch self { | ||
case let .view(view): | ||
target = view | ||
case let .barButton(barButtonItem): | ||
target = barButtonItem.value(forKey: "view") as! UIView | ||
case let .tabBarItem(tabBarController, index): | ||
let tabBarItems = tabBarController.tabBar.subviews.filter({ $0.isUserInteractionEnabled }) | ||
guard index > -1, tabBarItems.count > index else { return UIView() } | ||
let tabBarItemView = tabBarItems[index] | ||
let frame = CGRect(x: tabBarItemView.frame.midX - 22, y: tabBarController.tabBar.frame.origin.y, width: 44, height: 44) | ||
target = UIView(frame: frame) | ||
case let .point(center, radius): | ||
target = UIView(frame: CGRect(x: 0, y: 0, width: radius * 2, height: radius * 2)) | ||
target.center = center | ||
case let .rect(frame): | ||
target = UIView(frame: frame) | ||
} | ||
return target | ||
} | ||
|
||
func path(translater: UIView) -> UIBezierPath { | ||
let translatedFrame = targetView.convert(targetView.bounds, to: translater) | ||
let spotlightFrame = translatedFrame.insetBy(dx: -8.0, dy: -8.0) // Add some breathing space for the spotlight | ||
return UIBezierPath(roundedRect: spotlightFrame, cornerRadius: spotlightFrame.height / 2.0) | ||
} | ||
|
||
func infinitesmalPath(translater: UIView) -> UIBezierPath { | ||
let spotlightFrame = targetView.convert(targetView.bounds, to: translater) | ||
let spotlightCenter = CGPoint(x: spotlightFrame.midX, y: spotlightFrame.midY) | ||
return UIBezierPath(roundedRect: CGRect(origin: spotlightCenter, size: CGSize.zero), cornerRadius: 0) | ||
} | ||
} |
Oops, something went wrong.