Skip to content

Instantly share code, notes, and snippets.

View fabiogiolito's full-sized avatar
🏠
Working from home

Fabio Giolito fabiogiolito

🏠
Working from home
View GitHub Profile
// ===========================================================================
// Starting point:
// - Sketch file with many shapes (icons).
// - Ideally each icon category is its own page named appropriately.
// How to use it:
// - Open Sketch file and press Ctrl + Shift + K.
// - Paste script and click "Run".
@fabiogiolito
fabiogiolito / Layout.swift
Created November 28, 2018 15:06
Swift Layout Extension
import UIKit
extension UIView {
// ----------------------------------------------------------------------
// Make it cleaner to add all your elements as subviews in a single line.
// Example:
// view.addSubviews([coverImage, titleLabel, followButton, …])
func addSubviews(_ views: [UIView]) {
class StyledButton: UIButton {
enum ButtonStyle {
case large, wide, tag
case primary, secondary
case tintPrimary, tintSecondary
case …
}
var styles = [ButtonStyle]() {
didSet {
applyStyles()
class StyledButton: UIButton {
...
convenience init(
text: String? = nil,
image: UIImage? = nil,
styles: [ButtonStyle] = []
){
self.init(type: .system)
class StyledButton: UIButton {
...
func applyStyles() {
// Apply regular style
self.backgroundColor = .clear
self.titleLabel?.font = Theme.fontButtonText
self.tintColor = Theme.colorShadowLight.cgColor
let btn1 = StyledButton(text: "Regular")
let btn2 = StyledButton(text: "Tint primary wide", styles: [.tintPrimary, .wide])
let btn3 = StyledButton(text: "Primary large", styles: [.primary, .large])
let btn4 = StyledButton(text: "Large", styles: [.large])
let btn5 = StyledButton(text: "Label Button", styles: [.label, .tintPrimary])
let btn6 = StyledButton(text: "Secondary", styles: [.secondary])
let btn7 = StyledButton(text: "Tag", styles: [.tag])
let btn8 = StyledButton(text: "Vertical", image: UIImage(named: "circle"), styles: [.iconVertical, .tintSecondary])
let btn9 = StyledButton(text: "With icon", image: UIImage(named: "circle"), styles: [.iconHorizontal])
let btn10 = StyledButton(image: UIImage(named: "star"))
extension UILabel {
func setLineSpacing(lineSpacing: CGFloat) {
let text = self.text
if let text = text {
let attributeString = NSMutableAttributedString(string: text)
let style = NSMutableParagraphStyle()
style.lineSpacing = lineSpacing
style.alignment = self.textAlignment
attributeString.addAttribute(NSAttributedString.Key.paragraphStyle, value: style, range: NSMakeRange(0, text.count))
self.attributedText = attributeString
//
// InstagramFeed.swift
// Landmarks
//
// Created by Fabio Giolito on 04/06/2019.
// Copyright © 2019 Apple. All rights reserved.
//
// ===================================================
// This is just a quick UI test.
//
// InstagramFeed.swift
// Landmarks
//
// Created by Fabio Giolito on 04/06/2019.
// Copyright © 2019 Apple. All rights reserved.
//
// ===================================================
// This is just a quick UI test.
@fabiogiolito
fabiogiolito / FacebookReactions.swift
Last active August 11, 2022 15:25
Recreating Facebook Reactions with SwiftUI. Demo Video: https://twitter.com/fabiogiolito/status/1142226669471748096
//
// FacebookReactions.swift
//
// Created by Fabio Giolito on 10/06/2019.
// Follow me: https://twitter.com/fabiogiolito
//
import SwiftUI
struct FacebookReactions : View {