HMSegmentedControl Documentation

repository·master·Indexed 26 days ago

https://github.com/heshammegid/hmsegmentedcontrol

A customizable drop-in replacement for iOS UISegmentedControl that supports text and image segments, advanced styling, and horizontal scrolling for large numbers of segments. Compatible with Swift and Objective-C for iOS 7 and up.

Tokens
404
Snippets
2
Records
3
Agent score
38%

What's inside HMSegmentedControl

  1. Overview of HMSegmentedControl features

    master

    HMSegmentedControl is a highly customizable replacement for UISegmentedControl with the following capabilities:

    • Content Support: Supports both text and images.
    • Styling: Multiple sizing and selection styles, plus advanced title styling (font, color, kerning, shadow, etc.).
    • Scrolling: Supports horizontal scrolling for an infinite number of segments.
    • Compatibility: Works with Swift and Objective-C; supports iOS 7 and up (updated for Xcode 11, iOS 13, and Swift 5).
  2. Initialize and use HMSegmentedControl

    master

    To create a segmented control with default styling, initialize HMSegmentedControl with an array of section titles. You can then set its frame and add a target to handle value change events, similar to UISegmentedControl.

    let segmentedControl = HMSegmentedControl(sectionTitles: [
        "Trending",
        "News",
        "Library"
    ])
    
    segmentedControl.frame = CGRect(x: 0, y: 0, width: 100, height: 40)
    segmentedControl.addTarget(self, action: #selector(segmentedControlChangedValue(segmentedControl:)), for: .valueChanged)
    view.addSubview(segmentedControl)