Skip to content

Commit

Permalink
Bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip Kluz committed Sep 28, 2015
1 parent 05ce9d1 commit baa8c3a
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Demo/DemoViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class DemoViewController: UIViewController {
}

@IBAction func showAnimatedErrorHUD(sender: AnyObject) {
PKHUD.sharedHUD.contentView = PKHUDErrorAnimation()
PKHUD.sharedHUD.contentView = PKHUDErrorView()
PKHUD.sharedHUD.show()
PKHUD.sharedHUD.hide(afterDelay: 2.0);
}
Expand Down
2 changes: 1 addition & 1 deletion PKHUD.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = 'PKHUD'
s.module_name = 'PKHUD'
s.version = '2.2.1'
s.version = '2.2.2'
s.summary = 'A Swift based reimplementation of the Apple HUD (Volume, Ringer, Rotation,…) for iOS 8'
s.homepage = 'https://github.com/pkluz/PKHUD'
s.license = 'MIT'
Expand Down
8 changes: 4 additions & 4 deletions PKHUD.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/* Begin PBXBuildFile section */
F908BEC01BB849290015E5A8 /* PKHUDSuccessView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F908BEBF1BB849290015E5A8 /* PKHUDSuccessView.swift */; settings = {ASSET_TAGS = (); }; };
F908BEC31BB84D0B0015E5A8 /* PKHUDAnimating.swift in Sources */ = {isa = PBXBuildFile; fileRef = F908BEC21BB84D0B0015E5A8 /* PKHUDAnimating.swift */; settings = {ASSET_TAGS = (); }; };
F908BEC51BB852C60015E5A8 /* PKHUDErrorAnimation.swift in Sources */ = {isa = PBXBuildFile; fileRef = F908BEC41BB852C60015E5A8 /* PKHUDErrorAnimation.swift */; settings = {ASSET_TAGS = (); }; };
F908BEC51BB852C60015E5A8 /* PKHUDErrorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F908BEC41BB852C60015E5A8 /* PKHUDErrorView.swift */; settings = {ASSET_TAGS = (); }; };
F908BEC81BB85EA70015E5A8 /* PKHUDProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F908BEC71BB85EA70015E5A8 /* PKHUDProgressView.swift */; settings = {ASSET_TAGS = (); }; };
F935B1581B2B8088003C3734 /* Storyboard.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F935B1571B2B8088003C3734 /* Storyboard.storyboard */; };
F935B15A1B2B865A003C3734 /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F935B1591B2B865A003C3734 /* Launch Screen.storyboard */; };
Expand Down Expand Up @@ -69,7 +69,7 @@
/* Begin PBXFileReference section */
F908BEBF1BB849290015E5A8 /* PKHUDSuccessView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PKHUDSuccessView.swift; sourceTree = "<group>"; };
F908BEC21BB84D0B0015E5A8 /* PKHUDAnimating.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PKHUDAnimating.swift; sourceTree = "<group>"; };
F908BEC41BB852C60015E5A8 /* PKHUDErrorAnimation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PKHUDErrorAnimation.swift; sourceTree = "<group>"; };
F908BEC41BB852C60015E5A8 /* PKHUDErrorView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PKHUDErrorView.swift; sourceTree = "<group>"; };
F908BEC71BB85EA70015E5A8 /* PKHUDProgressView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PKHUDProgressView.swift; sourceTree = "<group>"; };
F935B1571B2B8088003C3734 /* Storyboard.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Storyboard.storyboard; sourceTree = "<group>"; };
F935B1591B2B865A003C3734 /* Launch Screen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = "Launch Screen.storyboard"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -137,7 +137,7 @@
F935B16C1B2B8F8B003C3734 /* PKHUDStatusView.swift */,
F935B1661B2B8D8C003C3734 /* PKHUDSystemActivityIndicatorView.swift */,
F908BEBF1BB849290015E5A8 /* PKHUDSuccessView.swift */,
F908BEC41BB852C60015E5A8 /* PKHUDErrorAnimation.swift */,
F908BEC41BB852C60015E5A8 /* PKHUDErrorView.swift */,
F908BEC71BB85EA70015E5A8 /* PKHUDProgressView.swift */,
);
name = "Content Views";
Expand Down Expand Up @@ -346,7 +346,7 @@
F908BEC81BB85EA70015E5A8 /* PKHUDProgressView.swift in Sources */,
F935B16D1B2B8F8B003C3734 /* PKHUDStatusView.swift in Sources */,
F908BEC01BB849290015E5A8 /* PKHUDSuccessView.swift in Sources */,
F908BEC51BB852C60015E5A8 /* PKHUDErrorAnimation.swift in Sources */,
F908BEC51BB852C60015E5A8 /* PKHUDErrorView.swift in Sources */,
F935B16B1B2B8EA6003C3734 /* PKHUDSubtitleView.swift in Sources */,
F935B15D1B2B8C20003C3734 /* PKHUDSquareBaseView.swift in Sources */,
F996325219514FEF001F73CA /* Window.swift in Sources */,
Expand Down
41 changes: 28 additions & 13 deletions PKHUD/PKHUD.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,18 @@ public class PKHUD: NSObject {

public override init () {
super.init()
NSNotificationCenter.defaultCenter().addObserver(self,
selector: Selector("willEnterForeground"),
name: UIApplicationWillEnterForegroundNotification,
object: nil)
userInteractionOnUnderlyingViewsEnabled = false
window.frameView.autoresizingMask = [.FlexibleLeftMargin, .FlexibleRightMargin, .FlexibleTopMargin, .FlexibleBottomMargin]
}

internal func willEnterForeground() {
self.startAnimatingContentView()
}

public var dimsBackground = true
public var userInteractionOnUnderlyingViewsEnabled: Bool {
get {
Expand All @@ -37,16 +45,17 @@ public class PKHUD: NSObject {
}
}

public var isVisible: Bool {
return !window.hidden
}

public var contentView: UIView {
get {
return window.frameView.content
}
set {
window.frameView.content = newValue
if !window.hidden && contentView.conformsToProtocol(PKHUDAnimating) {
let animatingContentView = contentView as! PKHUDAnimating
animatingContentView.startAnimation()
}
startAnimatingContentView()
}
}

Expand All @@ -56,10 +65,7 @@ public class PKHUD: NSObject {
window.showBackground(animated: true)
}

if contentView.conformsToProtocol(PKHUDAnimating) {
let animatingContentView = contentView as! PKHUDAnimating
animatingContentView.startAnimation()
}
startAnimatingContentView()
}

public func hide(animated anim: Bool = true) {
Expand All @@ -68,10 +74,7 @@ public class PKHUD: NSObject {
window.hideBackground(animated: true)
}

if contentView.conformsToProtocol(PKHUDAnimating) {
let animatingContentView = contentView as! PKHUDAnimating
animatingContentView.stopAnimation?()
}
stopAnimatingContentView()
}

private var hideTimer: NSTimer?
Expand All @@ -80,7 +83,19 @@ public class PKHUD: NSObject {
hideTimer = NSTimer.scheduledTimerWithTimeInterval(delay, target: self, selector: Selector("hideAnimated"), userInfo: nil, repeats: false)
}

// MARK: Helper
internal func startAnimatingContentView() {
if isVisible && contentView.conformsToProtocol(PKHUDAnimating) {
let animatingContentView = contentView as! PKHUDAnimating
animatingContentView.startAnimation()
}
}

internal func stopAnimatingContentView() {
if contentView.conformsToProtocol(PKHUDAnimating) {
let animatingContentView = contentView as! PKHUDAnimating
animatingContentView.stopAnimation?()
}
}

internal func hideAnimated() -> Void {
hide(animated: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

import UIKit

/// PKHUDErrorAnimation provides an animated error (cross) view.
public class PKHUDErrorAnimation: PKHUDSquareBaseView, PKHUDAnimating {
/// PKHUDErrorView provides an animated error (cross) view.
public class PKHUDErrorView: PKHUDSquareBaseView, PKHUDAnimating {

var dashOneLayer = PKHUDErrorAnimation.generateDashLayer()
var dashTwoLayer = PKHUDErrorAnimation.generateDashLayer()
var dashOneLayer = PKHUDErrorView.generateDashLayer()
var dashTwoLayer = PKHUDErrorView.generateDashLayer()

class func generateDashLayer() -> CAShapeLayer {
let dash = CAShapeLayer()
Expand Down

0 comments on commit baa8c3a

Please sign in to comment.