Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Adapted from https://github.com/github/gitignore/blob/master/Objective-C.gitignore

# Finder
.DS_Store

# Xcode
## Build generated
build/
DerivedData/

## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/

## Other
*.moved-aside
*.xccheckout
*.xcscmblueprint

## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control

Pods/

# Add this line if you want to avoid checking in source code from the Xcode workspace
# *.xcworkspace

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output

# Code Injection
#
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode

iOSInjectionProject/
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0830;
LastUpgradeCheck = 0830;
LastUpgradeCheck = 1000;
TargetAttributes = {
A9334EB51F518B2800445BBE = {
CreatedOnToolsVersion = 8.3.2;
Expand Down Expand Up @@ -264,15 +264,23 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand All @@ -295,7 +303,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.3;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand All @@ -314,15 +322,23 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand All @@ -339,7 +355,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.3;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
Expand All @@ -354,14 +370,14 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = AJParticlesLoadingView/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.ajparticlesloadingview;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = 1;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
Expand All @@ -372,14 +388,14 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = AJParticlesLoadingView/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.ajparticlesloadingview;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = 1;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -11,99 +11,95 @@ import SpriteKit

class AJParticlesLoadingView: UIView {

// MARK: - Public Properties
// MARK: -

public var duration = 2.0
public var particlesSize: CGFloat = 5.0
public var particlesSpeed : CGFloat = 80.0
public var clockwiseRotation: Bool = false
public var particleImage = ParticleImage.spark

public var emitterNode: SKEmitterNode? = nil {
didSet {
if let emitter = emitterNode {
scene.setEmitterNode(emitter)
}
// MARK: - Public Properties
// MARK: -

public var duration = 2.0
public var particlesSize: CGFloat = 5.0
public var particlesSpeed : CGFloat = 80.0
public var clockwiseRotation: Bool = false
public var particleImage = ParticleImage.spark

public var emitterNode: SKEmitterNode? = nil {
didSet {
if let emitter = emitterNode {
scene.setEmitterNode(emitter)
}
}
}

public var particleEffect = ParticleEffect.snow {
didSet {
if let _ = scene {
do {
let emitter = try particleFileLoad.createEmitterNode(with: particleEffect, particleImgName: particleImage.rawValue)
scene.setEmitterNode(emitter)
} catch {
print("Could not find the particles file")
}
} else {
setAJParticlesLoadingView()
public var particleEffect = ParticleEffect.snow {
didSet {
if let _ = scene {
do {
let emitter = try particleFileLoad.createEmitterNode(with: particleEffect, particleImgName: particleImage.rawValue)
scene.setEmitterNode(emitter)
} catch {
print("Could not find the particles file")
}
}
// If scene isn't defined yet, scene will be defined later via
// setAJParticlesLoadingView() when self is added to a parent
// superview which willMove(...) will notice.
}
}

// MARK: - Private Properties
// MARK: -

private let particleFileLoad = ParticleFileLoader()
private var spriteKitView = SKView()
private var scene: ParticlesSprites!

// MARK: - Initialization
// MARK: -

override public init(frame: CGRect) {
super.init(frame: frame)
spriteKitView = SKView(frame: CGRect(x: 0, y: 0, width: frame.size.width, height: frame.size.height))
spriteKitView.backgroundColor = UIColor.clear
setAJParticlesLoadingView()
}

required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
spriteKitView = SKView(frame: CGRect(x: 0, y: 0, width: frame.size.width, height: frame.size.height))
spriteKitView.backgroundColor = UIColor.clear
setAJParticlesLoadingView()
}

func setAJParticlesLoadingView() {
do {
let emitter = try particleFileLoad.createEmitterNode(with: particleEffect, particleImgName:particleImage.rawValue)
scene = ParticlesSprites(size: frame.size, emitterNode: emitter)
spriteKitView.presentScene(scene)
addSubview(spriteKitView)
} catch {
print("Could not find the particles file")
}
}

public override func startAnimating() {
scene.startAnimating()
}

public override func stopAnimating() {
scene.stopAnimating()
}

public override func isEmitting() -> Bool {
return scene.isEmitting()
}

public override func willMove(toSuperview newSuperview: UIView?) {
scene.setAnimationPath()
// MARK: - Private Properties
// MARK: -

private let particleFileLoad = ParticleFileLoader()
private var spriteKitView = SKView()
private var scene: ParticlesSprites!

// MARK: - Initialization
// MARK: -

override public init(frame: CGRect) {
super.init(frame: frame)
spriteKitView.backgroundColor = UIColor.clear
}

required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
spriteKitView.backgroundColor = UIColor.clear
}

override func willMove(toSuperview newSuperview: UIView?) {
// Will be called once.
super.willMove(toSuperview:newSuperview)
setAJParticlesLoadingView()
scene.setAnimationPath()
}

func setAJParticlesLoadingView() {
do {
let emitter = try particleFileLoad.createEmitterNode(with: particleEffect, particleImgName:particleImage.rawValue)
scene = ParticlesSprites(size: frame.size, emitterNode: emitter)
spriteKitView.presentScene(scene)
addSubview(spriteKitView)
} catch {
print("Could not find the particles file")
}
}

override func layoutSubviews() {
// May be called multiple times due to rotations.
super.layoutSubviews()
// bounds = "view’s location and size in its own coordinate system"
// https://developer.apple.com/documentation/uikit/uiview/1622580-bounds
// frame = spriteKitView’s "location and size in its superview’s coordinate system"
// https://developer.apple.com/documentation/uikit/uiview/1622621-frame
spriteKitView.frame = bounds
}
}

public extension UIView {

public func addParticlesAnimation(with emitter: SKEmitterNode? = nil, effect: ParticleEffect? = nil , imgName : String? = nil) {

var spriteKitView = SKView()
spriteKitView = SKView(frame: CGRect(x: 0, y: 0, width: frame.size.width, height: frame.size.height))
let spriteKitView = SKView()
spriteKitView.frame = bounds
spriteKitView.backgroundColor = UIColor.clear

var scene: ParticlesSprites
if let emitter = emitter {
scene = ParticlesSprites(size: frame.size, emitterNode: emitter)
Expand Down Expand Up @@ -151,3 +147,4 @@ public extension UIView {
return false
}
}

Loading