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 DesignableLabel: UILabel { | |
// Tracking | |
@IBInspectable var tracking: CGFloat = 0.0 { | |
didSet { | |
if attributedText?.length == nil { return } | |
let attrStr = NSMutableAttributedString(attributedString: attributedText!) | |
let range = NSMakeRange(0, attributedText!.length) |
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 Date { | |
var startOfWeek: Date? { | |
let gregorian = Calendar(identifier: .gregorian) | |
guard let sunday = gregorian.date(from: gregorian.dateComponents([.yearForWeekOfYear, .weekOfYear], from: self)) else { return nil } | |
return gregorian.date(byAdding: .day, value: 1, to: sunday) | |
} | |
var endOfWeek: Date? { | |
let gregorian = Calendar(identifier: .gregorian) | |
guard let sunday = gregorian.date(from: gregorian.dateComponents([.yearForWeekOfYear, .weekOfYear], from: self)) else { return nil } |
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
class CustomTabBar: UITabBar { | |
@IBInspectable var height: CGFloat = 0.0 | |
override func sizeThatFits(_ size: CGSize) -> CGSize { | |
var sizeThatFits = super.sizeThatFits(size) | |
if height > 0.0 { | |
sizeThatFits.height = height | |
} | |
return sizeThatFits | |
} |
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
// | |
// OverlayPresentationController.swift | |
// AllIWantFor | |
// | |
// Created by Michael Nino Evensen on 13/09/2017. | |
// Copyright © 2017 Michael Evensen. All rights reserved. | |
// | |
import UIKit |
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
// These methods removes the necessity of having to clear the array for each run as it just mirrors whatever the document data is. | |
self.array = snapshot!.documents.flatMap({Model(dictionary: $0.data())}) | |
DispatchQueue.main.async { | |
self.tableView.reloadData() | |
} | |
// Or this is even better... | |
// Only check for document changes | |
snap.documentChanges.forEach { | |
diff in |
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 UIView { | |
func bindToKeyboard() { | |
NotificationCenter.default.addObserver(self, selector: #selector(UIView.keyboardWillChange(_:)), name: NSNotification.Name.UIKeyboardWillChangeFrame, object: nil) | |
} | |
@objc func keyboardWillChange(_ notification: NSNotification) { | |
let duration = notification.userInfo![UIKeyboardAnimationDurationUserInfoKey] as! Double | |
let curve = notification.userInfo![UIKeyboardAnimationCurveUserInfoKey] as! UInt | |
let curFrame = (notification.userInfo![UIKeyboardFrameBeginUserInfoKey] as! NSValue).cgRectValue |
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
// Set default properties | |
static defaultProps = { | |
numberOfItems: 1, | |
...Stack.defaultProps | |
} | |
// Items shown in property panel | |
static propertyControls: PropertyControls = { | |
numberOfItems: { | |
type: ControlType.Number, |
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
drawLabel(angle) { | |
var canvas: any = document.getElementById("canvas"), | |
ctx: CanvasRenderingContext2D = canvas.getContext('2d'); | |
// Clear canvas first | |
ctx.clearRect(0, 0, canvas.width, canvas.height); | |
canvas.width = 500; | |
// Draw text | |
ctx.font = "20px Helvetica"; |