Skip to content

Instantly share code, notes, and snippets.


Jeremy Fuellert jfuellert

  • Mayday Inc
  • Toronto, Ontario, Canada
View GitHub Profile
jfuellert / DynamicAttributedTextView.swift
Last active Jul 16, 2021
SwiftUI HTML string parsing Text component
View DynamicAttributedTextView.swift
struct DynamicAttributedTextView: UIViewRepresentable {
// MARK: - Constants
private static let attributes: [NSAttributedString.Key : Any] = [.font: CustomFont().UIKitFont()!,
.foregroundColor: UIColor.appPrimaryText,
.paragraphStyle: DynamicAttributedTextView.paragraphStyle]
private static let types: NSTextCheckingResult.CheckingType = [.link, .address, .phoneNumber]
private static let paragraphStyle: NSParagraphStyle = {
let paragraphStyle: NSMutableParagraphStyle = NSMutableParagraphStyle()
jfuellert / Example.swift
Created May 26, 2020
Easily read the size of a subview in SwiftUI
View Example.swift
struct ExampleView: View {
// MARK: - Properties
@State private var size: CGSize = .zero
// MARK: - Updates
func body(content: Content) -> some View {
Text("Size of this label: \(Int(self.size.width)),\(Int(self.size.height))")
.modifier(SizeModifier({self.size = $0}))
jfuellert / ScrollableView.swift
Last active Nov 19, 2021
A scrollable SwiftUI view, UIScrollView wrapper. ScrollableView lets you read and write content offsets for scrollview in SwiftUI, with and without animations.
View ScrollableView.swift
import SwiftUI
struct ScrollableView<Content: View>: UIViewControllerRepresentable, Equatable {
// MARK: - Coordinator
final class Coordinator: NSObject, UIScrollViewDelegate {
// MARK: - Properties
private let scrollView: UIScrollView
var offset: Binding<CGPoint>
jfuellert / gist:5bb0418871f0e30070aa
Created Jan 6, 2016
Returns a centered position CGRect for a given CGRect inside of a larger CGRect
View gist:5bb0418871f0e30070aa
/** Returns a centered position CGRect for a given CGRect inside of a larger CGRect */
CGRect centeredRect(CGRect outerRect, CGRect innerRect) {
CGRect centeredRect = innerRect;
centeredRect.origin.x = CGRectGetMidX(outerRect) - (CGRectGetWidth(innerRect) * 0.5f);
centeredRect.origin.y = CGRectGetMidY(outerRect) - (CGRectGetHeight(innerRect) * 0.5f);
return centeredRect;