Skip to content

Instantly share code, notes, and snippets.

// See also: Pro SwiftUI, Chapter 4 Custom Layouts
import SwiftUI
struct RelativeHStack: Layout {
enum Alignment {
case top, center, bottom
}
var alignment: Alignment = .center
@TAATHub
TAATHub / ChipsSelection.swift
Last active April 17, 2025 18:21
Responsive Chips Selection
// Responsive Chips Selection
// See Also: https://youtu.be/T82izB2XBMA?si=Cnf6rGdyisG8ZWoX
import SwiftUI
struct Tag: Hashable {
var name: String
var color: Color
}
import SwiftUI
import Combine
struct CountdownView: View {
let countdownSeconds: Int = 10
let numberOfDivision: Int = 36
let handSize: CGSize = .init(width: 8, height: 24)
let radius: CGFloat = 100
@State var count: Int = 10
// Gradient Border Animation
// See Also: https://x.com/sucodeee/status/1894700908824395843
import SwiftUI
struct ContentView: View {
@State var rotation: CGFloat = 0
var body: some View {
VStack(spacing: 40) {
@TAATHub
TAATHub / SegmentedControl.Swift
Created February 24, 2024 12:34
Custom Segmented Control with SwiftUI
protocol SegmentTypeProtocol: CaseIterable, Identifiable, Equatable {
var title: String { get }
var tintColor: Color? { get }
}
extension SegmentTypeProtocol {
var tintColor: Color? { nil }
}
struct SegmentedControl<SegmentType: SegmentTypeProtocol>: View where SegmentType.AllCases == [SegmentType] {