{"id":13610901,"url":"https://github.com/samvermette/SVSegmentedControl","last_synced_at":"2025-04-13T01:33:24.976Z","repository":{"id":1527593,"uuid":"1802145","full_name":"samvermette/SVSegmentedControl","owner":"samvermette","description":"A UISwitch-like segmented control for your iOS app.","archived":false,"fork":false,"pushed_at":"2013-06-13T08:47:56.000Z","size":603,"stargazers_count":1328,"open_issues_count":23,"forks_count":191,"subscribers_count":50,"default_branch":"master","last_synced_at":"2025-04-08T14:08:43.034Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://samvermette.com/255","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/samvermette.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-05-26T01:16:14.000Z","updated_at":"2025-03-22T19:47:35.000Z","dependencies_parsed_at":"2022-08-16T13:35:25.213Z","dependency_job_id":null,"html_url":"https://github.com/samvermette/SVSegmentedControl","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samvermette%2FSVSegmentedControl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samvermette%2FSVSegmentedControl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samvermette%2FSVSegmentedControl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samvermette%2FSVSegmentedControl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samvermette","download_url":"https://codeload.github.com/samvermette/SVSegmentedControl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248654036,"owners_count":21140236,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T19:01:49.204Z","updated_at":"2025-04-13T01:33:24.720Z","avatar_url":"https://github.com/samvermette.png","language":"Objective-C","readme":"# SVSegmentedControl\n\nSVSegmentedControl is a customizable `UIControl` class that mimics `UISegmentedControl` but that looks like an `UISwitch`.\n\n![SVSegmentedControl](http://f.cl.ly/items/213N0a1k2U2O0F3y053z/svsegmentedcontrol3.png)\n\n## Installation\n\n### From CocoaPods\n\nAdd `pod 'SVSegmentedControl'` to your Podfile or `pod 'SVSegmentedControl', :head` if you're feeling adventurous.\n\n### Manually\n\n_**Important note if your project doesn't use ARC**: you must add the `-fobjc-arc` compiler flag to `SVSegmentedControl.m` and `SVSegmentedThumb.m` in Target Settings \u003e Build Phases \u003e Compile Sources._\n\n* Drag the `SVSegmentedControl/SVSegmentedControl ` folder into your project. \n* Add the **QuartzCore** framework to your project.\n\n## Usage\n\n(see sample Xcode project in `/Demo`)\n\nIn its simplest form, this is how you create an SVSegmentedControl instance:\n\n```objective-c\nsegmentedControl = [[SVSegmentedControl alloc] initWithSectionTitles:[NSArray arrayWithObjects:@\"Section 1\", @\"Section 2\", nil]];\nsegmentedControl.changeHandler = ^(NSUInteger newIndex) {\n    // respond to index change\n};\n\n[self.view addSubview:segmentedControl];\n```\n\nYou can position it using either its `frame` or `center` property:\n\n## Customization\n\nSVSegmentedControl can be customized with the following properties:\n\n```objective-c\n@property (nonatomic, strong) NSArray *sectionTitles;\n@property (nonatomic, strong) NSArray *sectionImages;\n\n@property (nonatomic, readwrite) BOOL animateToInitialSelection; // default is NO\n@property (nonatomic, readwrite) BOOL crossFadeLabelsOnDrag; // default is NO\n\n@property (nonatomic, readwrite) BOOL mustSlideToChange; // default is NO - To make the control difficult to accidentally change, force the user to slide it\n@property (nonatomic, readwrite) CGFloat minimumOverlapToChange; // default is 0.66 - Only snap to a new segment if the thumb overlaps it by this fraction\n@property (nonatomic, readwrite) UIEdgeInsets touchTargetMargins; // default is UIEdgeInsetsMake(0, 0, 0, 0) - Enlarge touch target of control\n\n@property (nonatomic, strong) UIColor *backgroundTintColor; // default is [UIColor colorWithWhite:0.1 alpha:1]\n@property (nonatomic, retain) UIImage *backgroundImage; // default is nil\n\n@property (nonatomic, readwrite) CGFloat height; // default is 32.0\n@property (nonatomic, readwrite) UIEdgeInsets thumbEdgeInset; // default is UIEdgeInsetsMake(2, 2, 3, 2)\n@property (nonatomic, readwrite) UIEdgeInsets titleEdgeInsets; // default is UIEdgeInsetsMake(0, 10, 0, 10)\n@property (nonatomic, readwrite) CGFloat cornerRadius; // default is 4.0\n\n@property (nonatomic, retain) UIFont *font; // default is [UIFont boldSystemFontOfSize:15]\n@property (nonatomic, retain) UIColor *textColor; // default is [UIColor grayColor];\n@property (nonatomic, strong) UIColor *innerShadowColor; // default is [UIColor colorWithWhite:0 alpha:0.8]\n@property (nonatomic, retain) UIColor *textShadowColor;  // default is [UIColor blackColor]\n@property (nonatomic, readwrite) CGSize textShadowOffset;  // default is CGSizeMake(0, -1)\n```\n\nIts thumb (`SVSegmentedThumb`) can be customized as well: \n\n```objective-c\n@property (nonatomic, retain) UIImage *backgroundImage; // default is nil;\n@property (nonatomic, retain) UIImage *highlightedBackgroundImage; // default is nil;\n\n@property (nonatomic, retain) UIColor *tintColor; // default is [UIColor grayColor]\n@property (nonatomic, assign) UIColor *textColor; // default is [UIColor whiteColor]\n@property (nonatomic, assign) UIColor *textShadowColor; // default is [UIColor blackColor]\n@property (nonatomic, readwrite) CGSize textShadowOffset; // default is CGSizeMake(0, -1)\n@property (nonatomic, readwrite) BOOL shouldCastShadow; // default is YES (NO when backgroundImage is set)\n@property (nonatomic, assign) CGFloat gradientIntensity; // default is 0.15\n```\n\nTo customize the thumb's appearance, you'll have to set the properties through SVSegmentedControl's `thumb` property. For instance, setting the thumb's `tintColor` is done with:\n\n```objective-c\nsegmentedControl.thumb.tintColor = someColor;\n```\n\n## Responding to value changes\n\nYou can respond to value changes using a block handler:\n\n```objective-c\nsegmentedControl.changeHandler = ^(NSUInteger newIndex) {\n    // respond to index change\n};\n```\n\nIf you haven't fallen in love with blocks yet, you can still use the classic UIControl method:\n\n```objective-c\n[mySegmentedControl addTarget:self action:@selector(segmentedControlChangedValue:) forControlEvents:UIControlEventValueChanged];\n```\n\nProviding an action method ending with a semicolon, the sender object is therefore made accessible:\n\n```objective-c\n- (void)segmentedControlChangedValue:(SVSegmentedControl*)segmentedControl {\n\tNSLog(@\"segmentedControl did select index %i\", segmentedControl.selectedIndex);\n}\n```\n\n## Credits\n\nSVSegmentedControl is brought to you by [Sam Vermette](http://samvermette.com) and [contributors to the project](https://github.com/samvermette/SVSegmentedControl/contributors). If you have feature suggestions or bug reports, feel free to help out by sending pull requests or by [creating new issues](https://github.com/samvermette/SVSegmentedControl/issues/new). If you're using SVSegmentedControl in your project, attribution would be nice. ","funding_links":[],"categories":["Objective-C","etc"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamvermette%2FSVSegmentedControl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamvermette%2FSVSegmentedControl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamvermette%2FSVSegmentedControl/lists"}