This file contains hidden or 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
func scrollViewDidScroll(_ scrollView: UIScrollView) { | |
// Move ContainerView based on pagination from custom pagingScrollView | |
if scrollView == pagingScrollView { | |
// Calculate offset | |
let offset = (self.view.frame.size.height - bottomPeekMargin) - scrollView.contentOffset.y | |
// Overlay value (interpolates between 0.0 and 1.0 for end value) | |
// Note to self: contentOffset divided by endValue (where you end the animation) |
This file contains hidden or 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
// Instantiate | |
self.mapViewController = self.storyboard?.instantiateViewController(withIdentifier: "MapViewController") as? MapViewController | |
if let mapViewController = self.mapViewController { | |
// Add to Container View | |
self.mapViewContainerView.addSubview(mapViewController.view) | |
self.addChildViewController(mapViewController) | |
mapViewController.didMove(toParentViewController: self) | |
} |
This file contains hidden or 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
func add(asChildViewController viewController: UIViewController) { | |
// Add Child View Controller | |
self.addChildViewController(viewController) | |
// Add Child View as Subview | |
self.drawerContainerView.addSubview(viewController.view) | |
// self.view.addSubview(viewController.view) | |
// Configure Child View |
This file contains hidden or 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
@IBDesignable class UITextViewFixed: UITextView { | |
override func layoutSubviews() { | |
super.layoutSubviews() | |
setup() | |
} | |
func setup() { | |
textContainerInset = UIEdgeInsets.zero | |
textContainer.lineFragmentPadding = 0 | |
} | |
} |
This file contains hidden or 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
extension Int { | |
static func random(range: Range<Int>) -> Int { | |
var offset = 0 | |
if range.lowerBound < 0 { | |
offset = abs(range.lowerBound) | |
} | |
let mini = UInt32(range.lowerBound + offset) | |
let maxi = UInt32(range.upperBound + offset) |
This file contains hidden or 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
/* | |
* Custom Ordering Field: Descending | |
* - Trust me, this is the simplest way to do this with Firebase. 🤘 | |
*/ | |
imageObj["order"] = -image.uploadedAt.timeIntervalSince1970 | |
/* */ | |
FirebaseDatabaseReference.photos |
This file contains hidden or 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
// | |
// OneLineForEachSectionLayout.swift | |
// | |
// Created by Philipp Kinschel on 28/11/2016. | |
// | |
// | |
// | |
// very basic solution to layout one section in one line without linebreaks | |
// TODO: find name for the class | |
// |
This file contains hidden or 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
/// Global extension to remove all padding from all UITextView's. | |
extension UITextView { | |
open override func setNeedsDisplay() { | |
super.setNeedsDisplay() | |
textContainerInset = UIEdgeInsets.zero | |
textContainer.lineFragmentPadding = 0 | |
} | |
} |
This file contains hidden or 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
// Database Reference | |
var ref: DatabaseReference! | |
var handle: UInt! | |
var updateHandler: UInt! | |
// Local store | |
var wishes = [Wish]() | |
override func viewWillAppear(_ animated: Bool) { | |
super.viewWillAppear(animated) |
This file contains hidden or 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
import UIKit | |
@IBDesignable | |
class KerningLabel: UILabel { | |
@IBInspectable var kerning: CGFloat = 0.0 { | |
didSet { | |
if attributedText?.length == nil { return } | |
let attrStr = NSMutableAttributedString(attributedString: attributedText!) |