Skip to content

Instantly share code, notes, and snippets.

@bteapot
bteapot / gist:31192edbc6de7f2ce5d4
Last active June 22, 2017 23:18
UITableView expandable animated rows
#pragma mark - BTDurableView
@interface BTDurableView : UIView
@end
@implementation BTDurableView
//
@bteapot
bteapot / FlexibleTextAttachment.swift
Created September 19, 2019 14:29
NSTextAttachment with font-aligned image
final class FlexibleTextAttachment: NSTextAttachment {
// MARK: - Параметры
enum Resize: Int {
case none
case toLowercase
case toUppercase
case toLineHeight
}
@bteapot
bteapot / UIImage+Avatar, UIFont+Traits
Last active July 27, 2020 15:02
UIImage extension for generating two-letter avatars with reproducible color.
import Foundation
import UIKit
extension UIFont {
func with(traits: UIFontDescriptor.SymbolicTraits) -> UIFont {
if let fontDescriptor = self.fontDescriptor.withSymbolicTraits(traits) {
return UIFont(descriptor: fontDescriptor, size: 0)
} else {
return self
}
//
// SemanticVersion.swift
// library
//
// Created by Денис Либит on 27.07.2020.
//
import Foundation
@bteapot
bteapot / Millimetrovka.swift
Created April 27, 2021 11:20
Debug UIView with plotting paper grid.
#if DEBUG
import Foundation
import UIKit
public final class Millimetrovka: UIView {
public required init(
frame: CGRect,
mm: CGFloat = 10,
cm: CGFloat = 50
@bteapot
bteapot / Emptiness.swift
Created September 6, 2022 08:48
Radical solution for detection of emptiness in generic values
// MARK: - EmptinessDetector
internal struct EmptinessDetector<Wrapped> {
let value: Wrapped
init(_ value: Wrapped) {
self.value = value
}
var isEmpty: Bool {