Skip to content

Instantly share code, notes, and snippets.

View OksanaFedorchuk's full-sized avatar
🐙
Working hard

Oksana Fedorchuk OksanaFedorchuk

🐙
Working hard
View GitHub Profile
@OksanaFedorchuk
OksanaFedorchuk / DateExtension.swift
Created April 27, 2021 08:57
Extension of Date to calculate days/seconds between two days.
extension Date {
func daysBetweenDates(start: Date, end: Date) -> Int {
let days = Calendar.current.dateComponents([.day], from: start, to: end).day!
let returnDays = days+1
return returnDays
}
func secondsBetweenDates(start: Date, end: Date) -> Int {
let seconds = Calendar.current.dateComponents([.second], from: start, to: end).second!
@OksanaFedorchuk
OksanaFedorchuk / VCPresenter.swift
Last active April 23, 2021 13:05
ViewController Extension to instantiate VC, with identifiable protocol to pass storyboard identifiers
import UIKit
protocol StoryboardIdentifiable {
static var storyboardIdentifier: String { get }
}
extension StoryboardIdentifiable where Self: UIViewController {
static var storyboardIdentifier: String {
return String(describing: self)
}
@OksanaFedorchuk
OksanaFedorchuk / UIViewInOut.swift
Created April 21, 2021 14:13
Extension for UIView, to make pop up animation
extension UIView {
//adding subview to a view, animated
func animateIn(view: UIView) {
self.backgroundColor = .clear
self.addSubview(view)
view.transform = CGAffineTransform(scaleX: 1.2, y: 1.2)
view.alpha = 0
UIView.animate(withDuration: 0.3) {
view.transform = CGAffineTransform(scaleX: 1.0, y: 1.0)
@OksanaFedorchuk
OksanaFedorchuk / ProgressBar.swift
Created April 21, 2021 14:05
Horizontal and vertical progress bar
import UIKit
class ProgressBar: UIView {
// MARK: - Properties
@IBInspectable var color: UIColor = .gray {
didSet { setNeedsDisplay() }
}