Skip to content

Instantly share code, notes, and snippets.

View rursache's full-sized avatar
💻

Radu Ursache rursache

💻
View GitHub Profile
@rursache
rursache / CustomSegmentedControl.swift
Created April 4, 2026 12:35
Custom UISegmentControl with arbitrary views as the content
import UIKit
/// A `UISegmentedControl` subclass that displays custom views as segment content.
///
/// Segments are initialized with unique empty reference images. During `layoutSubviews()`,
/// the view hierarchy is walked to find the `UIImageView` matching each reference image,
/// and the custom view is installed as a sibling in that image view's superview.
public final class CustomSegmentedControl: UISegmentedControl {
// MARK: - Properties