Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated to Swift 4.2 #49

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 16 additions & 14 deletions Pod/Classes/SAConfettiView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ public class SAConfettiView: UIView {

func setup() {
colors = [UIColor(red:0.95, green:0.40, blue:0.27, alpha:1.0),
UIColor(red:1.00, green:0.78, blue:0.36, alpha:1.0),
UIColor(red:0.48, green:0.78, blue:0.64, alpha:1.0),
UIColor(red:0.30, green:0.76, blue:0.85, alpha:1.0),
UIColor(red:0.58, green:0.39, blue:0.55, alpha:1.0)]
UIColor(red:1.00, green:0.78, blue:0.36, alpha:1.0),
UIColor(red:0.48, green:0.78, blue:0.64, alpha:1.0),
UIColor(red:0.30, green:0.76, blue:0.85, alpha:1.0),
UIColor(red:0.58, green:0.39, blue:0.55, alpha:1.0)]
intensity = 0.5
type = .confetti
active = false
Expand Down Expand Up @@ -87,14 +87,16 @@ public class SAConfettiView: UIView {

let path = Bundle(for: SAConfettiView.self).path(forResource: "SAConfettiView", ofType: "bundle")
let bundle = Bundle(path: path!)
let imagePath = bundle?.path(forResource: fileName, ofType: "png")
let url = URL(fileURLWithPath: imagePath!)
do {
let data = try Data(contentsOf: url)
return UIImage(data: data)
} catch {
print(error)


if let imagePath = bundle?.path(forResource: fileName, ofType: "png") {
let url = URL(fileURLWithPath: imagePath)
let data = try? Data(contentsOf: url)
if let imageData = data {
return UIImage(data: imageData)
}
}

return nil
}

Expand All @@ -106,8 +108,8 @@ public class SAConfettiView: UIView {
confetti.color = color.cgColor
confetti.velocity = CGFloat(350.0 * intensity)
confetti.velocityRange = CGFloat(80.0 * intensity)
confetti.emissionLongitude = CGFloat(Double.pi)
confetti.emissionRange = CGFloat(Double.pi)
confetti.emissionLongitude = .pi
confetti.emissionRange = .pi / 4
confetti.spin = CGFloat(3.5 * intensity)
confetti.spinRange = CGFloat(4.0 * intensity)
confetti.scaleRange = CGFloat(intensity)
Expand All @@ -117,6 +119,6 @@ public class SAConfettiView: UIView {
}

public func isActive() -> Bool {
return self.active
return self.active
}
}