ETSegmentedView
ETSegmentedView copied to clipboard
A Lightweight Synchronous Segmented View for iOS

ETSegmentedView is a lightweight and synchronous custom segmented view for iOS platform. It's an easy-to-setup and fully customizable component.

Dependencies
ETSegmentedView depends on the POP animation framework by facebook.
Using CocoaPods
ETSegmentedView is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "ETSegmentedView"
And run pod install
Manually from Github
- Download source files from subdirectory
- Add the source files to your Xcode project.
- Import the
ETSegmentedView.hheader file.
Usage
To run the example project, clone the repo, and run from the Example directory first.
Here's the sample code to add ETSegmentedView to your any UIViewController or UIView
1. Initialize and customize the view
ETSegmentedView* sv = [[ETSegmentedView alloc]
initWithFrame:CGRectMake(10, 60, [[UIScreen mainScreen] bounds].size.width - 20, 260)];
sv.nonSelectionColor = [UIColor whiteColor];
sv.selectionColor = [UIColor darkGrayColor];
2. Set titles
[sv setTitles:@[@"Label", @"Image", @"WebView", @"Custom"]];
3. Set contents
UILabel* label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 70, 40)];
UIImageView* imageView = [UIImageView alloc] initWithImage:[UIImage imageNamed:@"photo.png"];
// you can access segmentedView's button container view height with : "sv.viewButtons"
UIWebView* webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, sv.frame.size.width, sv.frame.size.height - sv.viewButtons.frame.size.height)];
UIView* customView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 50)];
[arrayContents addObjectsFromArray:@[label, imageView, webView, customView]];
[sv setContents:arrayContents];
// if you are adding component to UIViewController
[self.view addSubview:sv];
Cheers! 🍻
License
ETSegmentedView is available under the MIT license. See the LICENSE file for more info.