ersentekin / ETSegmentedView

A Lightweight Synchronous Segmented View for iOS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

Version License Platform

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

  1. Download source files from subdirectory
  2. Add the source files to your Xcode project.
  3. Import the ETSegmentedView.h header 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.

About

A Lightweight Synchronous Segmented View for iOS

License:MIT License


Languages

Language:Objective-C 57.8%Language:Objective-C++ 25.6%Language:C++ 13.7%Language:Shell 2.4%Language:Ruby 0.4%Language:C 0.2%