Skip to content

Instantly share code, notes, and snippets.

@vinczebalazs
vinczebalazs / LoadingButton.swift
Last active January 29, 2020 12:27
A UIButton subclass which can display a loading spinner instead of its title.
import UIKit
class LoadingButton: UIButton {
// MARK: Public Properties
var spinnerSpeed = 0.75
var spinnerWidth: CGFloat = 4
var spinnerRadius = 30
var isSpinnerRounded = true
final class ExpandableLabel: UILabel {
private let collapsedHeight: CGFloat = 65
private var heightConstraint: NSLayoutConstraint!
override func awakeFromNib() {
super.awakeFromNib()
heightConstraint = NSLayoutConstraint(item: self, attribute: .height, relatedBy: .equal, toItem: nil,
attribute: .height, multiplier: 1, constant: collapsedHeight)
NSLayoutConstraint.activate([heightConstraint])
@vinczebalazs
vinczebalazs / UICollectionViewLeftAlignedLayout.swift
Created October 6, 2019 15:33
Left aligned collection view flow layout.
// MIT License
//
// Copyright (c) 2019 Balázs Vincze
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@vinczebalazs
vinczebalazs / color.m
Created May 12, 2016 20:36 — forked from kylefox/color.m
Generate a random color (UIColor) in Objective-C
/*
Distributed under The MIT License:
http://opensource.org/licenses/mit-license.php
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to