├── .gitignore ├── .travis.yml ├── Example ├── AppDelegate.h ├── AppDelegate.m ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Info.plist ├── LaunchScreen.xib ├── Main.storyboard ├── ViewController.h ├── ViewController.m └── main.m ├── LICENSE ├── NXTSegmentedControl.podspec ├── NXTSegmentedControl.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ ├── NXTSegmentedControl.xcscheme │ └── NXTSegmentedControlFramework.xcscheme ├── NXTSegmentedControl.xcworkspace └── contents.xcworkspacedata ├── NXTSegmentedControl ├── NXTSegmentedControl.h └── NXTSegmentedControl.m ├── NXTSegmentedControlFramework ├── Info.plist └── NXTSegmentedControlFramework.h ├── NXTSegmentedControlTests ├── Info.plist ├── NXTSegmentedControlSnapshotTests.m ├── NXTSegmentedControlTests.m └── ReferenceImages_64 │ └── NXTSegmentedControlSnapshotTests │ ├── testChangingTheFrameShouldKeepTheSelectedIndex_thumb should be over second segment@2x.png │ ├── testInheritingGlobalTintColor_should be tinted correctly@2x.png │ ├── testSegementedControl_CreatedWithCustomFrame_ShouldRelayoutSubviews_should re-layout with a new frame@2x.png │ ├── testSegmentedControl_ChangingSelectedTitleTextAttributes_ShouldUpdateSelectedLabels_should show bigger text on selected label@2x.png │ ├── testSegmentedControl_ChangingTintColor_ShouldUpdateTheTrackColor_should tint the background when tint color is changed.@2x.png │ ├── testSegmentedControl_ChangingTitleTextAttributes_AfterChangingSelectedTitleTextAttributes_ShouldKeepOriginalSelectedAttributes_should still bigger text under selection thumb@2x.png │ ├── testSegmentedControl_ChangingTitleTextAttributes_ShouldUpdateLabels_IncludingSelectedIfNotProvided_should show bigger text@2x.png │ ├── testSegmentedControl_ChangingTitle_ShouldUpdateLabels_should update label text@2x.png │ ├── testSegmentedControl_CreatedWithoutAFrame_ShouldProvideADefaultFrame_should provide a default frame@2x.png │ ├── testSegmentedControl_WithATonOfSegments_ShouldKeepTheLayoutLookingReasonable_should display a ton of segments reasonably.@2x.png │ ├── testSegmentedControl_WithColoredThumb_ShouldSetTheThumbsBackgroundColor_should have an orange thumb@2x.png │ ├── testSegmentedControl_WithLongText_ShouldClipTheText_should tint the background when tint color is changed.@2x.png │ ├── testSegmentedControl_WithMoreThan2Segments_ShouldLayoutMultipleSegments_should display more than 2 segments correctly.@2x.png │ ├── testSegmentedControl_WithSmallerThanNormalEdgeInsets_ShouldHaveASmallBorder_should have a 1 pixel border around the thumb.@2x.png │ └── testSettingSelectedIndexShouldMoveTheThumb_thumb should be over second segment@2x.png ├── Podfile ├── Podfile.lock ├── README.md ├── images └── demo.gif └── module.modulemap /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | Pods/ 27 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | osx_image: xcode8 3 | 4 | script: 5 | - xcodebuild test -workspace NXTSegmentedControl.xcworkspace -scheme NXTSegmentedControl -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.0' CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO | xcpretty 6 | - xcodebuild -workspace NXTSegmentedControl.xcworkspace -scheme NXTSegmentedControlFramework | xcpretty 7 | 8 | -------------------------------------------------------------------------------- /Example/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // NXTSegmentedControl 4 | // 5 | // Created by Patrick Mick on 3/5/15. 6 | // Copyright (c) 2015 Patrick Mick. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /Example/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // NXTSegmentedControl 4 | // 5 | // Created by Patrick Mick on 3/5/15. 6 | // Copyright (c) 2015 Patrick Mick. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /Example/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /Example/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.YayNext.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /Example/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Example/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // NXTSegmentedControl 4 | // 5 | // Created by Patrick Mick on 3/5/15. 6 | // Copyright (c) 2015 Patrick Mick. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Example/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // NXTSegmentedControl 4 | // 5 | // Created by Patrick Mick on 3/5/15. 6 | // Copyright (c) 2015 Patrick Mick. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "NXTSegmentedControl.h" 11 | 12 | @interface ViewController () { 13 | NXTSegmentedControl *_segmentedControl; 14 | UILabel *_selectedIndexLabel; 15 | } 16 | 17 | @end 18 | 19 | @implementation ViewController 20 | 21 | #pragma mark - Lifecycle 22 | 23 | - (void)viewDidLoad { 24 | [super viewDidLoad]; 25 | 26 | _segmentedControl = [[NXTSegmentedControl alloc] initWithItems:@[@"thing1", @"thing2"]]; 27 | _segmentedControl.accessibilityLabel = @"Segmented Control"; 28 | [_segmentedControl addTarget:self 29 | action:@selector(segmentedControlValueChanged:) 30 | forControlEvents:UIControlEventValueChanged]; 31 | [self.view addSubview:_segmentedControl]; 32 | 33 | _selectedIndexLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]; 34 | _selectedIndexLabel.textAlignment = NSTextAlignmentCenter; 35 | _selectedIndexLabel.text = @"0"; 36 | _selectedIndexLabel.accessibilityLabel = @"label"; 37 | [self.view addSubview:_selectedIndexLabel]; 38 | } 39 | 40 | - (void)viewDidLayoutSubviews { 41 | [super viewDidLayoutSubviews]; 42 | CGRect bounds = self.view.bounds; 43 | CGPoint screenCenter = CGPointMake(CGRectGetMidX(bounds), 44 | CGRectGetMidY(bounds)); 45 | _segmentedControl.center = screenCenter; 46 | _selectedIndexLabel.center = CGPointMake(screenCenter.x, screenCenter.y + 50); 47 | } 48 | 49 | #pragma mark - Actions 50 | 51 | - (void)segmentedControlValueChanged:(id)sender { 52 | NXTSegmentedControl *segmentedControl = (NXTSegmentedControl *)sender; 53 | NSString *t = [NSString stringWithFormat:@"%ld", (long)segmentedControl.selectedSegmentIndex]; 54 | NSLog(t); 55 | } 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /Example/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // NXTSegmentedControl 4 | // 5 | // Created by Patrick Mick on 3/5/15. 6 | // Copyright (c) 2015 Patrick Mick. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 YayNext 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /NXTSegmentedControl.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod spec lint NXTSegmentedControl.podspec' to ensure this is a 3 | # valid spec and to remove all comments including this before submitting the spec. 4 | # 5 | # To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html 6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | s.name = "NXTSegmentedControl" 11 | s.version = "1.0.10" 12 | s.summary = "A segmented control replacement that supports swiping, and animated transitions." 13 | s.homepage = "https://github.com/pmick/NXTSegmentedControl" 14 | s.license = { :type => "MIT", :file => "LICENSE" } 15 | s.author = { "Patrick Mick" => "patrickmick1@gmail.com" } 16 | s.social_media_url = "http://twitter.com/patrickmick" 17 | s.platform = :ios 18 | s.source = { :git => "https://github.com/YayNext/NXTSegmentedControl.git", :tag => "1.0.10" } 19 | s.source_files = "Classes", "NXTSegmentedControl/*.{h,m}" 20 | s.requires_arc = true 21 | end 22 | -------------------------------------------------------------------------------- /NXTSegmentedControl.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 0F2590C61AAF8F6300F965F9 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0F2590C41AAF8F6300F965F9 /* LaunchScreen.xib */; }; 11 | 0F2590C71AAF8F6300F965F9 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0F2590C51AAF8F6300F965F9 /* Main.storyboard */; }; 12 | 0FF2770E1AA8DD7500978C6F /* NXTSegmentedControlTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 0FF2770D1AA8DD7500978C6F /* NXTSegmentedControlTests.m */; }; 13 | 0FF277241AA8DDE400978C6F /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 0FF277191AA8DDE400978C6F /* AppDelegate.m */; }; 14 | 0FF277271AA8DDE400978C6F /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0FF2771F1AA8DDE400978C6F /* Images.xcassets */; }; 15 | 0FF277281AA8DDE400978C6F /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 0FF277201AA8DDE400978C6F /* Info.plist */; }; 16 | 0FF277291AA8DDE400978C6F /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 0FF277211AA8DDE400978C6F /* main.m */; }; 17 | 0FF2772A1AA8DDE400978C6F /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0FF277231AA8DDE400978C6F /* ViewController.m */; }; 18 | 0FF2772D1AA8DE2B00978C6F /* NXTSegmentedControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 0FF2772C1AA8DE2B00978C6F /* NXTSegmentedControl.m */; }; 19 | 0FF2772F1AA8E2F200978C6F /* NXTSegmentedControlSnapshotTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 0FF2772E1AA8E2F200978C6F /* NXTSegmentedControlSnapshotTests.m */; }; 20 | 2BD80BA52F3A8E7BAAD372E4 /* libPods-NXTSegmentedControl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CAFDA647356263662F940CF1 /* libPods-NXTSegmentedControl.a */; }; 21 | A65A1E861F8CC6B50071BFE6 /* NXTSegmentedControlFramework.h in Headers */ = {isa = PBXBuildFile; fileRef = A65A1E841F8CC6B50071BFE6 /* NXTSegmentedControlFramework.h */; settings = {ATTRIBUTES = (Public, ); }; }; 22 | A65A1E8A1F8CC6CA0071BFE6 /* NXTSegmentedControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 0FF2772C1AA8DE2B00978C6F /* NXTSegmentedControl.m */; }; 23 | A65A1E8B1F8CC7880071BFE6 /* NXTSegmentedControl.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FF2772B1AA8DE2B00978C6F /* NXTSegmentedControl.h */; settings = {ATTRIBUTES = (Public, ); }; }; 24 | CF396697ACE95E4FB1A69C1D /* libPods-NXTSegmentedControlTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E096BA1FA8F5BB9179249A59 /* libPods-NXTSegmentedControlTests.a */; }; 25 | /* End PBXBuildFile section */ 26 | 27 | /* Begin PBXContainerItemProxy section */ 28 | 0FF277081AA8DD7500978C6F /* PBXContainerItemProxy */ = { 29 | isa = PBXContainerItemProxy; 30 | containerPortal = 0FF276E61AA8DD7500978C6F /* Project object */; 31 | proxyType = 1; 32 | remoteGlobalIDString = 0FF276ED1AA8DD7500978C6F; 33 | remoteInfo = NXTSegmentedControl; 34 | }; 35 | /* End PBXContainerItemProxy section */ 36 | 37 | /* Begin PBXFileReference section */ 38 | 0BE90AA34AA9F62747AEF400 /* Pods-NXTSegmentedControlTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NXTSegmentedControlTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-NXTSegmentedControlTests/Pods-NXTSegmentedControlTests.release.xcconfig"; sourceTree = ""; }; 39 | 0F2590C41AAF8F6300F965F9 /* LaunchScreen.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = LaunchScreen.xib; sourceTree = ""; }; 40 | 0F2590C51AAF8F6300F965F9 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = ""; }; 41 | 0FF276EE1AA8DD7500978C6F /* NXTSegmentedControl.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NXTSegmentedControl.app; sourceTree = BUILT_PRODUCTS_DIR; }; 42 | 0FF277071AA8DD7500978C6F /* NXTSegmentedControlTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NXTSegmentedControlTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | 0FF2770C1AA8DD7500978C6F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 44 | 0FF2770D1AA8DD7500978C6F /* NXTSegmentedControlTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NXTSegmentedControlTests.m; sourceTree = ""; }; 45 | 0FF277181AA8DDE300978C6F /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 46 | 0FF277191AA8DDE400978C6F /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 47 | 0FF2771F1AA8DDE400978C6F /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 48 | 0FF277201AA8DDE400978C6F /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 49 | 0FF277211AA8DDE400978C6F /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 50 | 0FF277221AA8DDE400978C6F /* ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 51 | 0FF277231AA8DDE400978C6F /* ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 52 | 0FF2772B1AA8DE2B00978C6F /* NXTSegmentedControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NXTSegmentedControl.h; sourceTree = ""; }; 53 | 0FF2772C1AA8DE2B00978C6F /* NXTSegmentedControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NXTSegmentedControl.m; sourceTree = ""; }; 54 | 0FF2772E1AA8E2F200978C6F /* NXTSegmentedControlSnapshotTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NXTSegmentedControlSnapshotTests.m; sourceTree = ""; }; 55 | 3BA3D8E687A6C4D80A2D3506 /* Pods-NXTSegmentedControl.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NXTSegmentedControl.debug.xcconfig"; path = "Pods/Target Support Files/Pods-NXTSegmentedControl/Pods-NXTSegmentedControl.debug.xcconfig"; sourceTree = ""; }; 56 | 7CB0FEE8BDB21285B9A1A369 /* Pods-NXTSegmentedControlTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NXTSegmentedControlTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-NXTSegmentedControlTests/Pods-NXTSegmentedControlTests.debug.xcconfig"; sourceTree = ""; }; 57 | A65A1E821F8CC6B50071BFE6 /* NXTSegmentedControlFramework.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = NXTSegmentedControlFramework.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 58 | A65A1E841F8CC6B50071BFE6 /* NXTSegmentedControlFramework.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NXTSegmentedControlFramework.h; sourceTree = ""; }; 59 | A65A1E851F8CC6B50071BFE6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 60 | CAFDA647356263662F940CF1 /* libPods-NXTSegmentedControl.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-NXTSegmentedControl.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 61 | E096BA1FA8F5BB9179249A59 /* libPods-NXTSegmentedControlTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-NXTSegmentedControlTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 62 | E12B1E3A3885B15CBA9F347F /* Pods-NXTSegmentedControl.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NXTSegmentedControl.release.xcconfig"; path = "Pods/Target Support Files/Pods-NXTSegmentedControl/Pods-NXTSegmentedControl.release.xcconfig"; sourceTree = ""; }; 63 | /* End PBXFileReference section */ 64 | 65 | /* Begin PBXFrameworksBuildPhase section */ 66 | 0FF276EB1AA8DD7500978C6F /* Frameworks */ = { 67 | isa = PBXFrameworksBuildPhase; 68 | buildActionMask = 2147483647; 69 | files = ( 70 | 2BD80BA52F3A8E7BAAD372E4 /* libPods-NXTSegmentedControl.a in Frameworks */, 71 | ); 72 | runOnlyForDeploymentPostprocessing = 0; 73 | }; 74 | 0FF277041AA8DD7500978C6F /* Frameworks */ = { 75 | isa = PBXFrameworksBuildPhase; 76 | buildActionMask = 2147483647; 77 | files = ( 78 | CF396697ACE95E4FB1A69C1D /* libPods-NXTSegmentedControlTests.a in Frameworks */, 79 | ); 80 | runOnlyForDeploymentPostprocessing = 0; 81 | }; 82 | A65A1E7E1F8CC6B50071BFE6 /* Frameworks */ = { 83 | isa = PBXFrameworksBuildPhase; 84 | buildActionMask = 2147483647; 85 | files = ( 86 | ); 87 | runOnlyForDeploymentPostprocessing = 0; 88 | }; 89 | /* End PBXFrameworksBuildPhase section */ 90 | 91 | /* Begin PBXGroup section */ 92 | 0FF276E51AA8DD7500978C6F = { 93 | isa = PBXGroup; 94 | children = ( 95 | 0FF277171AA8DDA200978C6F /* Example */, 96 | 0FF276F01AA8DD7500978C6F /* NXTSegmentedControl */, 97 | 0FF2770A1AA8DD7500978C6F /* NXTSegmentedControlTests */, 98 | A65A1E831F8CC6B50071BFE6 /* NXTSegmentedControlFramework */, 99 | 0FF276EF1AA8DD7500978C6F /* Products */, 100 | 8DA88C44565C535CA8B0200D /* Pods */, 101 | 7958B7B9A24D42D2BC2C67A3 /* Frameworks */, 102 | ); 103 | sourceTree = ""; 104 | }; 105 | 0FF276EF1AA8DD7500978C6F /* Products */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | 0FF276EE1AA8DD7500978C6F /* NXTSegmentedControl.app */, 109 | 0FF277071AA8DD7500978C6F /* NXTSegmentedControlTests.xctest */, 110 | A65A1E821F8CC6B50071BFE6 /* NXTSegmentedControlFramework.framework */, 111 | ); 112 | name = Products; 113 | sourceTree = ""; 114 | }; 115 | 0FF276F01AA8DD7500978C6F /* NXTSegmentedControl */ = { 116 | isa = PBXGroup; 117 | children = ( 118 | 0FF2772B1AA8DE2B00978C6F /* NXTSegmentedControl.h */, 119 | 0FF2772C1AA8DE2B00978C6F /* NXTSegmentedControl.m */, 120 | ); 121 | path = NXTSegmentedControl; 122 | sourceTree = ""; 123 | }; 124 | 0FF2770A1AA8DD7500978C6F /* NXTSegmentedControlTests */ = { 125 | isa = PBXGroup; 126 | children = ( 127 | 0FF2770D1AA8DD7500978C6F /* NXTSegmentedControlTests.m */, 128 | 0FF2770B1AA8DD7500978C6F /* Supporting Files */, 129 | 0FF2772E1AA8E2F200978C6F /* NXTSegmentedControlSnapshotTests.m */, 130 | ); 131 | path = NXTSegmentedControlTests; 132 | sourceTree = ""; 133 | }; 134 | 0FF2770B1AA8DD7500978C6F /* Supporting Files */ = { 135 | isa = PBXGroup; 136 | children = ( 137 | 0FF2770C1AA8DD7500978C6F /* Info.plist */, 138 | ); 139 | name = "Supporting Files"; 140 | sourceTree = ""; 141 | }; 142 | 0FF277171AA8DDA200978C6F /* Example */ = { 143 | isa = PBXGroup; 144 | children = ( 145 | 0F2590C41AAF8F6300F965F9 /* LaunchScreen.xib */, 146 | 0F2590C51AAF8F6300F965F9 /* Main.storyboard */, 147 | 0FF277181AA8DDE300978C6F /* AppDelegate.h */, 148 | 0FF277191AA8DDE400978C6F /* AppDelegate.m */, 149 | 0FF2771F1AA8DDE400978C6F /* Images.xcassets */, 150 | 0FF277201AA8DDE400978C6F /* Info.plist */, 151 | 0FF277211AA8DDE400978C6F /* main.m */, 152 | 0FF277221AA8DDE400978C6F /* ViewController.h */, 153 | 0FF277231AA8DDE400978C6F /* ViewController.m */, 154 | ); 155 | path = Example; 156 | sourceTree = ""; 157 | }; 158 | 7958B7B9A24D42D2BC2C67A3 /* Frameworks */ = { 159 | isa = PBXGroup; 160 | children = ( 161 | E096BA1FA8F5BB9179249A59 /* libPods-NXTSegmentedControlTests.a */, 162 | CAFDA647356263662F940CF1 /* libPods-NXTSegmentedControl.a */, 163 | ); 164 | name = Frameworks; 165 | sourceTree = ""; 166 | }; 167 | 8DA88C44565C535CA8B0200D /* Pods */ = { 168 | isa = PBXGroup; 169 | children = ( 170 | 7CB0FEE8BDB21285B9A1A369 /* Pods-NXTSegmentedControlTests.debug.xcconfig */, 171 | 0BE90AA34AA9F62747AEF400 /* Pods-NXTSegmentedControlTests.release.xcconfig */, 172 | 3BA3D8E687A6C4D80A2D3506 /* Pods-NXTSegmentedControl.debug.xcconfig */, 173 | E12B1E3A3885B15CBA9F347F /* Pods-NXTSegmentedControl.release.xcconfig */, 174 | ); 175 | name = Pods; 176 | sourceTree = ""; 177 | }; 178 | A65A1E831F8CC6B50071BFE6 /* NXTSegmentedControlFramework */ = { 179 | isa = PBXGroup; 180 | children = ( 181 | A65A1E841F8CC6B50071BFE6 /* NXTSegmentedControlFramework.h */, 182 | A65A1E851F8CC6B50071BFE6 /* Info.plist */, 183 | ); 184 | path = NXTSegmentedControlFramework; 185 | sourceTree = ""; 186 | }; 187 | /* End PBXGroup section */ 188 | 189 | /* Begin PBXHeadersBuildPhase section */ 190 | A65A1E7F1F8CC6B50071BFE6 /* Headers */ = { 191 | isa = PBXHeadersBuildPhase; 192 | buildActionMask = 2147483647; 193 | files = ( 194 | A65A1E8B1F8CC7880071BFE6 /* NXTSegmentedControl.h in Headers */, 195 | A65A1E861F8CC6B50071BFE6 /* NXTSegmentedControlFramework.h in Headers */, 196 | ); 197 | runOnlyForDeploymentPostprocessing = 0; 198 | }; 199 | /* End PBXHeadersBuildPhase section */ 200 | 201 | /* Begin PBXNativeTarget section */ 202 | 0FF276ED1AA8DD7500978C6F /* NXTSegmentedControl */ = { 203 | isa = PBXNativeTarget; 204 | buildConfigurationList = 0FF277111AA8DD7500978C6F /* Build configuration list for PBXNativeTarget "NXTSegmentedControl" */; 205 | buildPhases = ( 206 | 852F2D5B54F226CD20240F31 /* [CP] Check Pods Manifest.lock */, 207 | 0FF276EA1AA8DD7500978C6F /* Sources */, 208 | 0FF276EB1AA8DD7500978C6F /* Frameworks */, 209 | 0FF276EC1AA8DD7500978C6F /* Resources */, 210 | CF0C8B5A970BC6497F6E90B8 /* [CP] Embed Pods Frameworks */, 211 | F3A6F22688EC999858581B9C /* [CP] Copy Pods Resources */, 212 | ); 213 | buildRules = ( 214 | ); 215 | dependencies = ( 216 | ); 217 | name = NXTSegmentedControl; 218 | productName = NXTSegmentedControl; 219 | productReference = 0FF276EE1AA8DD7500978C6F /* NXTSegmentedControl.app */; 220 | productType = "com.apple.product-type.application"; 221 | }; 222 | 0FF277061AA8DD7500978C6F /* NXTSegmentedControlTests */ = { 223 | isa = PBXNativeTarget; 224 | buildConfigurationList = 0FF277141AA8DD7500978C6F /* Build configuration list for PBXNativeTarget "NXTSegmentedControlTests" */; 225 | buildPhases = ( 226 | 1E62C24C8D6A456508F924EB /* [CP] Check Pods Manifest.lock */, 227 | 0FF277031AA8DD7500978C6F /* Sources */, 228 | 0FF277041AA8DD7500978C6F /* Frameworks */, 229 | 0FF277051AA8DD7500978C6F /* Resources */, 230 | 2DF876D2CAB397DF2305FF43 /* [CP] Embed Pods Frameworks */, 231 | BDFA8C3B1697BC134603FECB /* [CP] Copy Pods Resources */, 232 | ); 233 | buildRules = ( 234 | ); 235 | dependencies = ( 236 | 0FF277091AA8DD7500978C6F /* PBXTargetDependency */, 237 | ); 238 | name = NXTSegmentedControlTests; 239 | productName = NXTSegmentedControlTests; 240 | productReference = 0FF277071AA8DD7500978C6F /* NXTSegmentedControlTests.xctest */; 241 | productType = "com.apple.product-type.bundle.unit-test"; 242 | }; 243 | A65A1E811F8CC6B50071BFE6 /* NXTSegmentedControlFramework */ = { 244 | isa = PBXNativeTarget; 245 | buildConfigurationList = A65A1E891F8CC6B50071BFE6 /* Build configuration list for PBXNativeTarget "NXTSegmentedControlFramework" */; 246 | buildPhases = ( 247 | A65A1E7D1F8CC6B50071BFE6 /* Sources */, 248 | A65A1E7E1F8CC6B50071BFE6 /* Frameworks */, 249 | A65A1E7F1F8CC6B50071BFE6 /* Headers */, 250 | A65A1E801F8CC6B50071BFE6 /* Resources */, 251 | ); 252 | buildRules = ( 253 | ); 254 | dependencies = ( 255 | ); 256 | name = NXTSegmentedControlFramework; 257 | productName = NXTSegmentedControlFramework; 258 | productReference = A65A1E821F8CC6B50071BFE6 /* NXTSegmentedControlFramework.framework */; 259 | productType = "com.apple.product-type.framework"; 260 | }; 261 | /* End PBXNativeTarget section */ 262 | 263 | /* Begin PBXProject section */ 264 | 0FF276E61AA8DD7500978C6F /* Project object */ = { 265 | isa = PBXProject; 266 | attributes = { 267 | LastUpgradeCheck = 0610; 268 | ORGANIZATIONNAME = "Patrick Mick"; 269 | TargetAttributes = { 270 | 0FF276ED1AA8DD7500978C6F = { 271 | CreatedOnToolsVersion = 6.1.1; 272 | DevelopmentTeam = U3X9LL8C4R; 273 | }; 274 | 0FF277061AA8DD7500978C6F = { 275 | CreatedOnToolsVersion = 6.1.1; 276 | TestTargetID = 0FF276ED1AA8DD7500978C6F; 277 | }; 278 | A65A1E811F8CC6B50071BFE6 = { 279 | CreatedOnToolsVersion = 9.0; 280 | ProvisioningStyle = Automatic; 281 | }; 282 | }; 283 | }; 284 | buildConfigurationList = 0FF276E91AA8DD7500978C6F /* Build configuration list for PBXProject "NXTSegmentedControl" */; 285 | compatibilityVersion = "Xcode 3.2"; 286 | developmentRegion = English; 287 | hasScannedForEncodings = 0; 288 | knownRegions = ( 289 | en, 290 | ); 291 | mainGroup = 0FF276E51AA8DD7500978C6F; 292 | productRefGroup = 0FF276EF1AA8DD7500978C6F /* Products */; 293 | projectDirPath = ""; 294 | projectRoot = ""; 295 | targets = ( 296 | 0FF276ED1AA8DD7500978C6F /* NXTSegmentedControl */, 297 | 0FF277061AA8DD7500978C6F /* NXTSegmentedControlTests */, 298 | A65A1E811F8CC6B50071BFE6 /* NXTSegmentedControlFramework */, 299 | ); 300 | }; 301 | /* End PBXProject section */ 302 | 303 | /* Begin PBXResourcesBuildPhase section */ 304 | 0FF276EC1AA8DD7500978C6F /* Resources */ = { 305 | isa = PBXResourcesBuildPhase; 306 | buildActionMask = 2147483647; 307 | files = ( 308 | 0FF277281AA8DDE400978C6F /* Info.plist in Resources */, 309 | 0F2590C61AAF8F6300F965F9 /* LaunchScreen.xib in Resources */, 310 | 0FF277271AA8DDE400978C6F /* Images.xcassets in Resources */, 311 | 0F2590C71AAF8F6300F965F9 /* Main.storyboard in Resources */, 312 | ); 313 | runOnlyForDeploymentPostprocessing = 0; 314 | }; 315 | 0FF277051AA8DD7500978C6F /* Resources */ = { 316 | isa = PBXResourcesBuildPhase; 317 | buildActionMask = 2147483647; 318 | files = ( 319 | ); 320 | runOnlyForDeploymentPostprocessing = 0; 321 | }; 322 | A65A1E801F8CC6B50071BFE6 /* Resources */ = { 323 | isa = PBXResourcesBuildPhase; 324 | buildActionMask = 2147483647; 325 | files = ( 326 | ); 327 | runOnlyForDeploymentPostprocessing = 0; 328 | }; 329 | /* End PBXResourcesBuildPhase section */ 330 | 331 | /* Begin PBXShellScriptBuildPhase section */ 332 | 1E62C24C8D6A456508F924EB /* [CP] Check Pods Manifest.lock */ = { 333 | isa = PBXShellScriptBuildPhase; 334 | buildActionMask = 2147483647; 335 | files = ( 336 | ); 337 | inputPaths = ( 338 | ); 339 | name = "[CP] Check Pods Manifest.lock"; 340 | outputPaths = ( 341 | ); 342 | runOnlyForDeploymentPostprocessing = 0; 343 | shellPath = /bin/sh; 344 | shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; 345 | showEnvVarsInLog = 0; 346 | }; 347 | 2DF876D2CAB397DF2305FF43 /* [CP] Embed Pods Frameworks */ = { 348 | isa = PBXShellScriptBuildPhase; 349 | buildActionMask = 2147483647; 350 | files = ( 351 | ); 352 | inputPaths = ( 353 | ); 354 | name = "[CP] Embed Pods Frameworks"; 355 | outputPaths = ( 356 | ); 357 | runOnlyForDeploymentPostprocessing = 0; 358 | shellPath = /bin/sh; 359 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-NXTSegmentedControlTests/Pods-NXTSegmentedControlTests-frameworks.sh\"\n"; 360 | showEnvVarsInLog = 0; 361 | }; 362 | 852F2D5B54F226CD20240F31 /* [CP] Check Pods Manifest.lock */ = { 363 | isa = PBXShellScriptBuildPhase; 364 | buildActionMask = 2147483647; 365 | files = ( 366 | ); 367 | inputPaths = ( 368 | ); 369 | name = "[CP] Check Pods Manifest.lock"; 370 | outputPaths = ( 371 | ); 372 | runOnlyForDeploymentPostprocessing = 0; 373 | shellPath = /bin/sh; 374 | shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; 375 | showEnvVarsInLog = 0; 376 | }; 377 | BDFA8C3B1697BC134603FECB /* [CP] Copy Pods Resources */ = { 378 | isa = PBXShellScriptBuildPhase; 379 | buildActionMask = 2147483647; 380 | files = ( 381 | ); 382 | inputPaths = ( 383 | ); 384 | name = "[CP] Copy Pods Resources"; 385 | outputPaths = ( 386 | ); 387 | runOnlyForDeploymentPostprocessing = 0; 388 | shellPath = /bin/sh; 389 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-NXTSegmentedControlTests/Pods-NXTSegmentedControlTests-resources.sh\"\n"; 390 | showEnvVarsInLog = 0; 391 | }; 392 | CF0C8B5A970BC6497F6E90B8 /* [CP] Embed Pods Frameworks */ = { 393 | isa = PBXShellScriptBuildPhase; 394 | buildActionMask = 2147483647; 395 | files = ( 396 | ); 397 | inputPaths = ( 398 | ); 399 | name = "[CP] Embed Pods Frameworks"; 400 | outputPaths = ( 401 | ); 402 | runOnlyForDeploymentPostprocessing = 0; 403 | shellPath = /bin/sh; 404 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-NXTSegmentedControl/Pods-NXTSegmentedControl-frameworks.sh\"\n"; 405 | showEnvVarsInLog = 0; 406 | }; 407 | F3A6F22688EC999858581B9C /* [CP] Copy Pods Resources */ = { 408 | isa = PBXShellScriptBuildPhase; 409 | buildActionMask = 2147483647; 410 | files = ( 411 | ); 412 | inputPaths = ( 413 | ); 414 | name = "[CP] Copy Pods Resources"; 415 | outputPaths = ( 416 | ); 417 | runOnlyForDeploymentPostprocessing = 0; 418 | shellPath = /bin/sh; 419 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-NXTSegmentedControl/Pods-NXTSegmentedControl-resources.sh\"\n"; 420 | showEnvVarsInLog = 0; 421 | }; 422 | /* End PBXShellScriptBuildPhase section */ 423 | 424 | /* Begin PBXSourcesBuildPhase section */ 425 | 0FF276EA1AA8DD7500978C6F /* Sources */ = { 426 | isa = PBXSourcesBuildPhase; 427 | buildActionMask = 2147483647; 428 | files = ( 429 | 0FF2772A1AA8DDE400978C6F /* ViewController.m in Sources */, 430 | 0FF277291AA8DDE400978C6F /* main.m in Sources */, 431 | 0FF277241AA8DDE400978C6F /* AppDelegate.m in Sources */, 432 | 0FF2772D1AA8DE2B00978C6F /* NXTSegmentedControl.m in Sources */, 433 | ); 434 | runOnlyForDeploymentPostprocessing = 0; 435 | }; 436 | 0FF277031AA8DD7500978C6F /* Sources */ = { 437 | isa = PBXSourcesBuildPhase; 438 | buildActionMask = 2147483647; 439 | files = ( 440 | 0FF2770E1AA8DD7500978C6F /* NXTSegmentedControlTests.m in Sources */, 441 | 0FF2772F1AA8E2F200978C6F /* NXTSegmentedControlSnapshotTests.m in Sources */, 442 | ); 443 | runOnlyForDeploymentPostprocessing = 0; 444 | }; 445 | A65A1E7D1F8CC6B50071BFE6 /* Sources */ = { 446 | isa = PBXSourcesBuildPhase; 447 | buildActionMask = 2147483647; 448 | files = ( 449 | A65A1E8A1F8CC6CA0071BFE6 /* NXTSegmentedControl.m in Sources */, 450 | ); 451 | runOnlyForDeploymentPostprocessing = 0; 452 | }; 453 | /* End PBXSourcesBuildPhase section */ 454 | 455 | /* Begin PBXTargetDependency section */ 456 | 0FF277091AA8DD7500978C6F /* PBXTargetDependency */ = { 457 | isa = PBXTargetDependency; 458 | target = 0FF276ED1AA8DD7500978C6F /* NXTSegmentedControl */; 459 | targetProxy = 0FF277081AA8DD7500978C6F /* PBXContainerItemProxy */; 460 | }; 461 | /* End PBXTargetDependency section */ 462 | 463 | /* Begin XCBuildConfiguration section */ 464 | 0FF2770F1AA8DD7500978C6F /* Debug */ = { 465 | isa = XCBuildConfiguration; 466 | buildSettings = { 467 | ALWAYS_SEARCH_USER_PATHS = NO; 468 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 469 | CLANG_CXX_LIBRARY = "libc++"; 470 | CLANG_ENABLE_MODULES = YES; 471 | CLANG_ENABLE_OBJC_ARC = YES; 472 | CLANG_WARN_BOOL_CONVERSION = YES; 473 | CLANG_WARN_CONSTANT_CONVERSION = YES; 474 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 475 | CLANG_WARN_EMPTY_BODY = YES; 476 | CLANG_WARN_ENUM_CONVERSION = YES; 477 | CLANG_WARN_INT_CONVERSION = YES; 478 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 479 | CLANG_WARN_UNREACHABLE_CODE = YES; 480 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 481 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 482 | COPY_PHASE_STRIP = NO; 483 | ENABLE_STRICT_OBJC_MSGSEND = YES; 484 | GCC_C_LANGUAGE_STANDARD = gnu99; 485 | GCC_DYNAMIC_NO_PIC = NO; 486 | GCC_OPTIMIZATION_LEVEL = 0; 487 | GCC_PREPROCESSOR_DEFINITIONS = ( 488 | "DEBUG=1", 489 | "$(inherited)", 490 | ); 491 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 492 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 493 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 494 | GCC_WARN_UNDECLARED_SELECTOR = YES; 495 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 496 | GCC_WARN_UNUSED_FUNCTION = YES; 497 | GCC_WARN_UNUSED_VARIABLE = YES; 498 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 499 | MTL_ENABLE_DEBUG_INFO = YES; 500 | ONLY_ACTIVE_ARCH = YES; 501 | SDKROOT = iphoneos; 502 | TARGETED_DEVICE_FAMILY = "1,2"; 503 | }; 504 | name = Debug; 505 | }; 506 | 0FF277101AA8DD7500978C6F /* Release */ = { 507 | isa = XCBuildConfiguration; 508 | buildSettings = { 509 | ALWAYS_SEARCH_USER_PATHS = NO; 510 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 511 | CLANG_CXX_LIBRARY = "libc++"; 512 | CLANG_ENABLE_MODULES = YES; 513 | CLANG_ENABLE_OBJC_ARC = YES; 514 | CLANG_WARN_BOOL_CONVERSION = YES; 515 | CLANG_WARN_CONSTANT_CONVERSION = YES; 516 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 517 | CLANG_WARN_EMPTY_BODY = YES; 518 | CLANG_WARN_ENUM_CONVERSION = YES; 519 | CLANG_WARN_INT_CONVERSION = YES; 520 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 521 | CLANG_WARN_UNREACHABLE_CODE = YES; 522 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 523 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 524 | COPY_PHASE_STRIP = YES; 525 | ENABLE_NS_ASSERTIONS = NO; 526 | ENABLE_STRICT_OBJC_MSGSEND = YES; 527 | GCC_C_LANGUAGE_STANDARD = gnu99; 528 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 529 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 530 | GCC_WARN_UNDECLARED_SELECTOR = YES; 531 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 532 | GCC_WARN_UNUSED_FUNCTION = YES; 533 | GCC_WARN_UNUSED_VARIABLE = YES; 534 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 535 | MTL_ENABLE_DEBUG_INFO = NO; 536 | SDKROOT = iphoneos; 537 | TARGETED_DEVICE_FAMILY = "1,2"; 538 | VALIDATE_PRODUCT = YES; 539 | }; 540 | name = Release; 541 | }; 542 | 0FF277121AA8DD7500978C6F /* Debug */ = { 543 | isa = XCBuildConfiguration; 544 | baseConfigurationReference = 3BA3D8E687A6C4D80A2D3506 /* Pods-NXTSegmentedControl.debug.xcconfig */; 545 | buildSettings = { 546 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 547 | INFOPLIST_FILE = "$(SRCROOT)/Example/Info.plist"; 548 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 549 | PRODUCT_NAME = "$(TARGET_NAME)"; 550 | }; 551 | name = Debug; 552 | }; 553 | 0FF277131AA8DD7500978C6F /* Release */ = { 554 | isa = XCBuildConfiguration; 555 | baseConfigurationReference = E12B1E3A3885B15CBA9F347F /* Pods-NXTSegmentedControl.release.xcconfig */; 556 | buildSettings = { 557 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 558 | INFOPLIST_FILE = "$(SRCROOT)/Example/Info.plist"; 559 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 560 | PRODUCT_NAME = "$(TARGET_NAME)"; 561 | }; 562 | name = Release; 563 | }; 564 | 0FF277151AA8DD7500978C6F /* Debug */ = { 565 | isa = XCBuildConfiguration; 566 | baseConfigurationReference = 7CB0FEE8BDB21285B9A1A369 /* Pods-NXTSegmentedControlTests.debug.xcconfig */; 567 | buildSettings = { 568 | BUNDLE_LOADER = "$(TEST_HOST)"; 569 | FRAMEWORK_SEARCH_PATHS = ( 570 | "$(SDKROOT)/Developer/Library/Frameworks", 571 | "$(inherited)", 572 | ); 573 | GCC_PREPROCESSOR_DEFINITIONS = ( 574 | "DEBUG=1", 575 | "$(inherited)", 576 | "FB_REFERENCE_IMAGE_DIR=\"\\\"$(SOURCE_ROOT)/$(PROJECT_NAME)Tests/ReferenceImages\\\"\"", 577 | ); 578 | INFOPLIST_FILE = NXTSegmentedControlTests/Info.plist; 579 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 580 | PRODUCT_NAME = "$(TARGET_NAME)"; 581 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NXTSegmentedControl.app/NXTSegmentedControl"; 582 | }; 583 | name = Debug; 584 | }; 585 | 0FF277161AA8DD7500978C6F /* Release */ = { 586 | isa = XCBuildConfiguration; 587 | baseConfigurationReference = 0BE90AA34AA9F62747AEF400 /* Pods-NXTSegmentedControlTests.release.xcconfig */; 588 | buildSettings = { 589 | BUNDLE_LOADER = "$(TEST_HOST)"; 590 | FRAMEWORK_SEARCH_PATHS = ( 591 | "$(SDKROOT)/Developer/Library/Frameworks", 592 | "$(inherited)", 593 | ); 594 | INFOPLIST_FILE = NXTSegmentedControlTests/Info.plist; 595 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 596 | PRODUCT_NAME = "$(TARGET_NAME)"; 597 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NXTSegmentedControl.app/NXTSegmentedControl"; 598 | }; 599 | name = Release; 600 | }; 601 | A65A1E871F8CC6B50071BFE6 /* Debug */ = { 602 | isa = XCBuildConfiguration; 603 | buildSettings = { 604 | CLANG_ANALYZER_NONNULL = YES; 605 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 606 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 607 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 608 | CLANG_WARN_COMMA = YES; 609 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 610 | CLANG_WARN_INFINITE_RECURSION = YES; 611 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 612 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 613 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 614 | CLANG_WARN_STRICT_PROTOTYPES = YES; 615 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 616 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 617 | CODE_SIGN_IDENTITY = "iPhone Developer"; 618 | CODE_SIGN_STYLE = Automatic; 619 | CURRENT_PROJECT_VERSION = 1; 620 | DEBUG_INFORMATION_FORMAT = dwarf; 621 | DEFINES_MODULE = YES; 622 | DYLIB_COMPATIBILITY_VERSION = 1; 623 | DYLIB_CURRENT_VERSION = 1; 624 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 625 | ENABLE_TESTABILITY = YES; 626 | GCC_C_LANGUAGE_STANDARD = gnu11; 627 | GCC_NO_COMMON_BLOCKS = YES; 628 | INFOPLIST_FILE = NXTSegmentedControlFramework/Info.plist; 629 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 630 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 631 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 632 | MODULEMAP_FILE = module.modulemap; 633 | PRODUCT_BUNDLE_IDENTIFIER = com.YayNext.NXTSegmentedControlFramework; 634 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 635 | SKIP_INSTALL = YES; 636 | TARGETED_DEVICE_FAMILY = "1,2"; 637 | VERSIONING_SYSTEM = "apple-generic"; 638 | VERSION_INFO_PREFIX = ""; 639 | }; 640 | name = Debug; 641 | }; 642 | A65A1E881F8CC6B50071BFE6 /* Release */ = { 643 | isa = XCBuildConfiguration; 644 | buildSettings = { 645 | CLANG_ANALYZER_NONNULL = YES; 646 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 647 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 648 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 649 | CLANG_WARN_COMMA = YES; 650 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 651 | CLANG_WARN_INFINITE_RECURSION = YES; 652 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 653 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 654 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 655 | CLANG_WARN_STRICT_PROTOTYPES = YES; 656 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 657 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 658 | CODE_SIGN_IDENTITY = "iPhone Developer"; 659 | CODE_SIGN_STYLE = Automatic; 660 | COPY_PHASE_STRIP = NO; 661 | CURRENT_PROJECT_VERSION = 1; 662 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 663 | DEFINES_MODULE = YES; 664 | DYLIB_COMPATIBILITY_VERSION = 1; 665 | DYLIB_CURRENT_VERSION = 1; 666 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 667 | GCC_C_LANGUAGE_STANDARD = gnu11; 668 | GCC_NO_COMMON_BLOCKS = YES; 669 | INFOPLIST_FILE = NXTSegmentedControlFramework/Info.plist; 670 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 671 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 672 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 673 | MODULEMAP_FILE = module.modulemap; 674 | PRODUCT_BUNDLE_IDENTIFIER = com.YayNext.NXTSegmentedControlFramework; 675 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 676 | SKIP_INSTALL = YES; 677 | TARGETED_DEVICE_FAMILY = "1,2"; 678 | VERSIONING_SYSTEM = "apple-generic"; 679 | VERSION_INFO_PREFIX = ""; 680 | }; 681 | name = Release; 682 | }; 683 | /* End XCBuildConfiguration section */ 684 | 685 | /* Begin XCConfigurationList section */ 686 | 0FF276E91AA8DD7500978C6F /* Build configuration list for PBXProject "NXTSegmentedControl" */ = { 687 | isa = XCConfigurationList; 688 | buildConfigurations = ( 689 | 0FF2770F1AA8DD7500978C6F /* Debug */, 690 | 0FF277101AA8DD7500978C6F /* Release */, 691 | ); 692 | defaultConfigurationIsVisible = 0; 693 | defaultConfigurationName = Release; 694 | }; 695 | 0FF277111AA8DD7500978C6F /* Build configuration list for PBXNativeTarget "NXTSegmentedControl" */ = { 696 | isa = XCConfigurationList; 697 | buildConfigurations = ( 698 | 0FF277121AA8DD7500978C6F /* Debug */, 699 | 0FF277131AA8DD7500978C6F /* Release */, 700 | ); 701 | defaultConfigurationIsVisible = 0; 702 | defaultConfigurationName = Release; 703 | }; 704 | 0FF277141AA8DD7500978C6F /* Build configuration list for PBXNativeTarget "NXTSegmentedControlTests" */ = { 705 | isa = XCConfigurationList; 706 | buildConfigurations = ( 707 | 0FF277151AA8DD7500978C6F /* Debug */, 708 | 0FF277161AA8DD7500978C6F /* Release */, 709 | ); 710 | defaultConfigurationIsVisible = 0; 711 | defaultConfigurationName = Release; 712 | }; 713 | A65A1E891F8CC6B50071BFE6 /* Build configuration list for PBXNativeTarget "NXTSegmentedControlFramework" */ = { 714 | isa = XCConfigurationList; 715 | buildConfigurations = ( 716 | A65A1E871F8CC6B50071BFE6 /* Debug */, 717 | A65A1E881F8CC6B50071BFE6 /* Release */, 718 | ); 719 | defaultConfigurationIsVisible = 0; 720 | defaultConfigurationName = Release; 721 | }; 722 | /* End XCConfigurationList section */ 723 | }; 724 | rootObject = 0FF276E61AA8DD7500978C6F /* Project object */; 725 | } 726 | -------------------------------------------------------------------------------- /NXTSegmentedControl.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /NXTSegmentedControl.xcodeproj/xcshareddata/xcschemes/NXTSegmentedControl.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 67 | 68 | 78 | 80 | 86 | 87 | 88 | 89 | 90 | 91 | 97 | 99 | 105 | 106 | 107 | 108 | 110 | 111 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /NXTSegmentedControl.xcodeproj/xcshareddata/xcschemes/NXTSegmentedControlFramework.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 33 | 34 | 35 | 36 | 47 | 48 | 54 | 55 | 56 | 57 | 58 | 59 | 65 | 66 | 72 | 73 | 74 | 75 | 77 | 78 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /NXTSegmentedControl.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /NXTSegmentedControl/NXTSegmentedControl.h: -------------------------------------------------------------------------------- 1 | // 2 | // NXTSegmentedControl.h 3 | // 4 | // 5 | // Created by Patrick Mick on 6/13/14. 6 | // 7 | // 8 | 9 | #import 10 | 11 | IB_DESIGNABLE 12 | @interface NXTSegmentedControl : UIControl 13 | 14 | /** 15 | * The number of items that the segmented control is currently displaying 16 | */ 17 | @property (nonatomic, readonly) NSUInteger numberOfSegments; 18 | 19 | /** 20 | * The index of the currently selected segment. A newly created control will 21 | * start with a selectedSegmentIndex of 0. 22 | */ 23 | @property (nonatomic, assign) NSInteger selectedSegmentIndex; 24 | 25 | /** 26 | * The white space between the edge of the control and the thumb. This value 27 | * defaults to 3.0f revealing some color around the selection thumb. 28 | */ 29 | @property (nonatomic, assign) CGFloat thumbEdgeInset; 30 | 31 | /** 32 | * The color of the selection thumb. By default, the thumb is white. 33 | */ 34 | @property (nonatomic, strong) UIColor *thumbColor; 35 | 36 | /** 37 | * Initializes a segmented control with the provided items. 38 | * 39 | * @param items NSString items that should be displayed in the segmented control 40 | * 41 | * @return The newly-initialized segmented control. 42 | */ 43 | - (instancetype)initWithItems:(NSArray *)items; 44 | 45 | 46 | /** 47 | * Adds the ability to change the selected segment without animation. Changing 48 | * the property would always animate. 49 | * 50 | * @param selectedSegmentIndex The selected index to change to 51 | * @param flag Flag that specificies whether or not the movement of 52 | * the thumb to the new index should be animated 53 | * 54 | */ 55 | - (void)setSelectedSegmentIndex:(NSInteger)selectedSegmentIndex animated:(BOOL)flag; 56 | 57 | /** 58 | * Replaces the text on a segment already in the segmented control. 59 | * 60 | * @param title A string to display in the segmented control 61 | * @param segment An index number identifying a segment between 0 and 62 | * numberOfSegments minus 1 63 | */ 64 | - (void)setTitle:(NSString *)title forSegmentAtIndex:(NSUInteger)segment; 65 | 66 | /** 67 | * Gets the title for a segment at a given index. 68 | * 69 | * @param segment An index number identifying a segment between 0 and 70 | * numberOfSegments minus 1 71 | * 72 | * @return Returns the string (title) assigned to the receiver as content. 73 | */ 74 | - (NSString *)titleForSegmentAtIndex:(NSUInteger)segment; 75 | 76 | /** 77 | * Returns the text attributes of the title for a given control state. Returns 78 | * nil if no custom title text attributes were set. 79 | * 80 | * @param state A control state. 81 | * 82 | * @return The text attributes of the title for state. 83 | */ 84 | - (NSDictionary *)titleTextAttributesForState:(UIControlState)state; 85 | 86 | /** 87 | * Sets the text attributes of the title for a given control state. Currently 88 | * supports: 89 | * 90 | * NSFontAttributeName 91 | * 92 | * Text color for text that is not selected will probably have its color 93 | * provided by thumbColor, but setting text color is currently not available 94 | * 95 | * Selected text color is provided through tintColor. 96 | * 97 | * @param attributes The text attributes of the title for state. 98 | * @param state A control state. 99 | */ 100 | - (void)setTitleTextAttributes:(NSDictionary *)attributes forState:(UIControlState)state; 101 | 102 | @end 103 | -------------------------------------------------------------------------------- /NXTSegmentedControl/NXTSegmentedControl.m: -------------------------------------------------------------------------------- 1 | // 2 | // NXTSegmentedControl.m 3 | // 4 | // 5 | // Created by Patrick Mick on 6/13/14. 6 | // 7 | // 8 | 9 | #import "NXTSegmentedControl.h" 10 | 11 | #define DEFAULT_THUMB_COLOR [UIColor whiteColor] 12 | 13 | static const NSInteger kNXTSegmentedControlDefaultHandleInset = 3; 14 | static const CGFloat kNXTSegmentedControlDefaultWidth = 200.0f; 15 | static const CGFloat kNXTSegmentedControlDefaultHeight = 33.0f; 16 | static const NSTimeInterval kNXTSegmentedControlDefaultAnimationDuration = 0.10f; 17 | 18 | @interface NXTSegmentedControl () { 19 | UIColor *_thumbColor; 20 | } 21 | 22 | @property (nonatomic, copy) NSMutableArray *segmentTitles; 23 | @property (nonatomic, strong) UIView *thumb; 24 | @property (nonatomic, strong) UIView *selectedLabelContainer; 25 | @property (nonatomic, strong) UIView *labelContainer; 26 | @property (nonatomic, copy) NSMutableArray *selectedLabels; 27 | @property (nonatomic, copy) NSMutableArray *labels; 28 | @property (nonatomic, strong) CALayer *maskLayer; 29 | @property (nonatomic, strong) UIView *thumbShowLayer; 30 | @property (nonatomic, copy) NSMutableDictionary *titleTextAttributes; 31 | 32 | @end 33 | 34 | @implementation NXTSegmentedControl 35 | 36 | #pragma mark - Lifecycle 37 | 38 | - (instancetype)initWithItems:(NSArray *)items { 39 | self = [super init]; 40 | if (!self) { 41 | return nil; 42 | } 43 | 44 | _segmentTitles = [items mutableCopy]; 45 | _titleTextAttributes = [NSMutableDictionary dictionary]; 46 | 47 | [self _setup]; 48 | [self _buildSegmentsArrayForItems:items]; 49 | 50 | self.frame = CGRectMake(0, 0, kNXTSegmentedControlDefaultWidth, kNXTSegmentedControlDefaultHeight); 51 | 52 | return self; 53 | } 54 | 55 | - (void)layoutSubviews { 56 | [super layoutSubviews]; 57 | 58 | [self _layoutLabels]; 59 | [self _layoutThumb]; 60 | } 61 | 62 | - (void)drawRect:(CGRect)rect { 63 | [super drawRect:rect]; 64 | [self _drawBackgroundWithTintColor]; 65 | 66 | // Fixes a bug that prevented labels from getting inherited tintColor from the window 67 | // because set tint color is not called. 68 | for (UILabel *label in self.selectedLabels) { 69 | label.textColor = self.tintColor; 70 | } 71 | } 72 | 73 | - (NSUInteger)numberOfSegments { 74 | return self.segmentTitles.count; 75 | } 76 | 77 | #pragma mark - Accessors 78 | 79 | - (void)setSelectedSegmentIndex:(NSInteger)selectedSegmentIndex { 80 | [self setSelectedSegmentIndex:selectedSegmentIndex animated:YES]; 81 | } 82 | 83 | - (CGFloat)thumbEdgeInset { 84 | if (_thumbEdgeInset <= 0) { 85 | return kNXTSegmentedControlDefaultHandleInset; 86 | } 87 | 88 | return _thumbEdgeInset; 89 | } 90 | 91 | - (void)setThumbColor:(UIColor *)thumbColor { 92 | _thumbColor = thumbColor; 93 | self.thumb.backgroundColor = thumbColor; 94 | } 95 | 96 | - (UIColor *)thumbColor { 97 | if (_thumbColor) { 98 | return _thumbColor; 99 | } 100 | 101 | return DEFAULT_THUMB_COLOR; 102 | } 103 | 104 | - (void)setTintColor:(UIColor *)tintColor { 105 | [super setTintColor:tintColor]; 106 | 107 | [self setNeedsDisplay]; 108 | } 109 | 110 | #pragma mark - Public Methods 111 | 112 | - (void)setSelectedSegmentIndex:(NSInteger)selectedSegmentIndex animated:(BOOL)flag { 113 | _selectedSegmentIndex = selectedSegmentIndex; 114 | [self _moveThumbToSelectedSegment:selectedSegmentIndex animated:flag]; 115 | } 116 | 117 | - (NSString *)titleForSegmentAtIndex:(NSUInteger)segment { 118 | return self.segmentTitles[segment]; 119 | } 120 | 121 | - (void)setTitle:(NSString *)title forSegmentAtIndex:(NSUInteger)segment { 122 | self.segmentTitles[segment] = title; 123 | [self _updateLabelWithTitle:title atIndex:segment]; 124 | } 125 | 126 | - (NSDictionary *)titleTextAttributesForState:(UIControlState)state { 127 | return self.titleTextAttributes[@(state)]; 128 | } 129 | 130 | - (void)setTitleTextAttributes:(NSDictionary *)attributes forState:(UIControlState)state { 131 | NSParameterAssert(attributes); 132 | 133 | self.titleTextAttributes[@(state)] = attributes; 134 | 135 | if (state == UIControlStateNormal) { 136 | [self _updateLabels:self.labels withAttributes:attributes]; 137 | 138 | if (!self.titleTextAttributes[@(UIControlStateSelected)]) { 139 | [self _updateLabels:self.selectedLabels withAttributes:attributes]; 140 | } 141 | } else if (state == UIControlStateSelected) { 142 | [self _updateLabels:self.selectedLabels withAttributes:attributes]; 143 | } 144 | } 145 | 146 | #pragma mark - Touches 147 | 148 | - (BOOL)beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event { 149 | [super beginTrackingWithTouch:touch withEvent:event]; 150 | 151 | CGPoint touchPoint = [touch locationInView:self]; 152 | BOOL shouldBeginTouches = [self _isValidTouchPoint:touchPoint]; 153 | 154 | return shouldBeginTouches; 155 | } 156 | 157 | - (BOOL)continueTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event { 158 | [super continueTrackingWithTouch:touch withEvent:event]; 159 | 160 | CGFloat horizontalDifference = [touch locationInView:self].x - [touch previousLocationInView:self].x; 161 | CGRect newThumbFrame = self.thumb.frame; 162 | newThumbFrame.origin.x += horizontalDifference; 163 | 164 | if (![self _isNewThumbFrameValid:newThumbFrame]) { 165 | newThumbFrame = [self _validatedThumbFrame:newThumbFrame]; 166 | } 167 | 168 | [self _moveThumbToNewFrame:newThumbFrame]; 169 | 170 | return YES; 171 | } 172 | 173 | - (void)endTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event { 174 | [super endTrackingWithTouch:touch withEvent:event]; 175 | 176 | NSInteger nearestIndex = [self _nearestIndexForCurrentThumbPosition]; 177 | 178 | if (nearestIndex != self.selectedSegmentIndex) { 179 | [self _updateSelectedIndexAndNotify:nearestIndex]; 180 | } else { 181 | [self _moveThumbToSelectedSegment:self.selectedSegmentIndex animated:YES]; 182 | } 183 | } 184 | 185 | #pragma mark - Private: Setup 186 | 187 | - (void)_setup { 188 | self.backgroundColor = [UIColor clearColor]; 189 | 190 | _selectedSegmentIndex = 0; 191 | 192 | _selectedLabels = [NSMutableArray array]; 193 | _labels = [NSMutableArray array]; 194 | 195 | [self _buildThumb]; 196 | [self _buildLabelContainers]; 197 | 198 | [self addSubview:self.thumb]; 199 | [self addSubview:self.labelContainer]; 200 | [self addSubview:self.selectedLabelContainer]; 201 | 202 | [self _buildMaskLayer]; 203 | [self _buildShowLayer]; 204 | 205 | self.selectedLabelContainer.layer.mask = self.maskLayer; 206 | [self.maskLayer addSublayer:self.thumbShowLayer.layer]; 207 | } 208 | 209 | - (void)_buildThumb { 210 | _thumb = [UIView new]; 211 | _thumb.backgroundColor = self.thumbColor; 212 | _thumb.userInteractionEnabled = NO; 213 | } 214 | 215 | - (void)_buildLabelContainers { 216 | self.selectedLabelContainer = [UIView new]; 217 | self.selectedLabelContainer.userInteractionEnabled = NO; 218 | 219 | self.labelContainer = [UIView new]; 220 | self.labelContainer.userInteractionEnabled = NO; 221 | } 222 | 223 | - (void)_buildMaskLayer { 224 | self.maskLayer = [CALayer layer]; 225 | self.maskLayer.backgroundColor = [[UIColor clearColor] CGColor]; 226 | } 227 | 228 | - (void)_buildShowLayer { 229 | self.thumbShowLayer = [UIView new]; 230 | self.thumbShowLayer.backgroundColor = [UIColor greenColor]; 231 | } 232 | 233 | - (void)_layoutMasks { 234 | self.maskLayer.frame = self.selectedLabelContainer.bounds; 235 | self.thumbShowLayer.bounds = [self _thumbRect]; 236 | self.thumbShowLayer.center = [self _centerForSegmentAtIndex:self.selectedSegmentIndex]; 237 | self.thumbShowLayer.layer.cornerRadius = CGRectGetHeight([self _thumbRect]) / 2.0f; 238 | } 239 | 240 | - (void)_buildSegmentsArrayForItems:(NSArray *)items { 241 | for (NSInteger idx = 0; idx < items.count; idx++) { 242 | NSString *title = items[idx]; 243 | if (![title isKindOfClass:[NSString class]]) { 244 | NSAssert(NO, @"Segmented control item must be a string! Item: %@", title); 245 | } 246 | 247 | [self _addLabelWithText:title atIndex:idx]; 248 | } 249 | } 250 | 251 | #pragma mark - Private: Layout & Calculation 252 | 253 | - (void)_layoutLabels { 254 | self.selectedLabelContainer.frame = self.bounds; 255 | self.labelContainer.frame = self.bounds; 256 | 257 | CGRect boundingRect = [self _thumbBoundingRect]; 258 | CGFloat segmentWidth = CGRectGetWidth(boundingRect) / [self numberOfSegments]; 259 | 260 | for (NSUInteger idx = 0; idx < self.selectedLabels.count; idx++) { 261 | UILabel *foregroundLabel = self.selectedLabels[idx]; 262 | UILabel *backgroundLabel = self.labels[idx]; 263 | 264 | CGRect desiredRect = [self _rectForLabelAtIndex:idx 265 | withSegmentWidth:segmentWidth 266 | boundingRect:boundingRect]; 267 | foregroundLabel.frame = desiredRect; 268 | backgroundLabel.frame = desiredRect; 269 | } 270 | 271 | [self _layoutMasks]; 272 | } 273 | 274 | - (void)_layoutThumb { 275 | _thumb.bounds = [self _thumbRect]; 276 | _thumb.center = [self _centerForSegmentAtIndex:self.selectedSegmentIndex]; 277 | _thumb.layer.cornerRadius = CGRectGetHeight([self _thumbRect]) / 2.0f; 278 | } 279 | 280 | - (CGRect)_rectForLabelAtIndex:(NSUInteger)index 281 | withSegmentWidth:(CGFloat)segmentWidth 282 | boundingRect:(CGRect)boundingRect { 283 | CGFloat x = (segmentWidth * index) + self.thumbEdgeInset; 284 | CGFloat y = self.thumbEdgeInset; 285 | CGFloat width = segmentWidth; 286 | CGFloat height = CGRectGetHeight(boundingRect); 287 | return CGRectMake(x, y, width, height); 288 | } 289 | 290 | - (void)_drawBackgroundWithTintColor { 291 | UIBezierPath *backgroundPath = [UIBezierPath 292 | bezierPathWithRoundedRect:self.bounds 293 | cornerRadius:CGRectGetHeight(self.bounds) / 2.0f]; 294 | [self.tintColor setFill]; 295 | [backgroundPath fill]; 296 | } 297 | 298 | - (BOOL)_isValidTouchPoint:(CGPoint)touchPoint { 299 | BOOL touchedSelectedSegment = CGRectContainsPoint([self _touchRectForSelectedSegment], touchPoint); 300 | BOOL touchedOtherSegment = NO; 301 | NSInteger selectedIndex = 0; 302 | for (NSInteger idx = 0; idx < self.segmentTitles.count; idx++) { 303 | if (CGRectContainsPoint([self _touchRectForSegmentAtIndex:idx], touchPoint) && 304 | idx != self.selectedSegmentIndex) { 305 | touchedOtherSegment = YES; 306 | selectedIndex = idx; 307 | [self _updateSelectedIndexAndNotify:idx]; 308 | break; 309 | } 310 | } 311 | 312 | BOOL shouldBeginTouches = NO; 313 | 314 | if (touchedSelectedSegment || touchedOtherSegment) { 315 | shouldBeginTouches = YES; 316 | } 317 | return shouldBeginTouches; 318 | } 319 | 320 | - (BOOL)_isNewThumbFrameValid:(CGRect)newThumbRect { 321 | return CGRectContainsRect([self _thumbBoundingRect], newThumbRect); 322 | } 323 | 324 | - (CGRect)_validatedThumbFrame:(CGRect)newThumbFrame { 325 | CGRect validatedThumbFrame = newThumbFrame; 326 | 327 | if (CGRectGetMaxX(newThumbFrame) > CGRectGetMaxX([self _thumbBoundingRect])) { 328 | CGFloat maxDifference = CGRectGetMaxX(newThumbFrame) - CGRectGetMaxX([self _thumbBoundingRect]); 329 | validatedThumbFrame.origin.x -= maxDifference; 330 | } else if (CGRectGetMinX(newThumbFrame) < CGRectGetMinX([self _thumbBoundingRect])) { 331 | CGFloat minDifference = CGRectGetMinX([self _thumbBoundingRect]) - CGRectGetMinX(newThumbFrame); 332 | validatedThumbFrame.origin.x += minDifference; 333 | } 334 | 335 | return validatedThumbFrame; 336 | } 337 | 338 | - (NSInteger)_nearestIndexForCurrentThumbPosition { 339 | NSInteger nearestIndex=0; 340 | CGFloat smallestDifference = CGFLOAT_MAX; 341 | 342 | for (NSInteger idx = 0; idx < self.segmentTitles.count; idx++) { 343 | CGRect segmentRect = [self _touchRectForSegmentAtIndex:idx]; 344 | CGPoint segmentCenter = 345 | CGPointMake(CGRectGetMidX(segmentRect), CGRectGetMidY(segmentRect)); 346 | 347 | CGFloat diffX = ABS(_thumb.center.x - segmentCenter.x); 348 | 349 | if (diffX < smallestDifference) { 350 | smallestDifference = diffX; 351 | nearestIndex = idx; 352 | } 353 | } 354 | return nearestIndex; 355 | } 356 | 357 | - (void)_updateSelectedIndexAndNotify:(NSInteger)newIndex { 358 | self.selectedSegmentIndex = newIndex; 359 | [self sendActionsForControlEvents:UIControlEventValueChanged]; 360 | } 361 | 362 | - (void)_moveThumbToNewFrame:(CGRect)newThumbFrame { 363 | self.thumb.frame = newThumbFrame; 364 | self.thumbShowLayer.frame = newThumbFrame; 365 | } 366 | 367 | - (void)_addLabelWithText:(NSString *)title atIndex:(NSUInteger)index { 368 | UILabel *foregroundLabel = [self _labelWithTitle:title textColor:self.tintColor]; 369 | UILabel *backgroundLabel = [self _labelWithTitle:title textColor:[UIColor whiteColor]]; 370 | 371 | [self.selectedLabels insertObject:foregroundLabel atIndex:index]; 372 | [self.labels insertObject:backgroundLabel atIndex:index]; 373 | 374 | [self.selectedLabelContainer addSubview:foregroundLabel]; 375 | [self.labelContainer addSubview:backgroundLabel]; 376 | } 377 | 378 | - (UILabel *)_labelWithTitle:(NSString *)title textColor:(UIColor *)textColor { 379 | UILabel *label = [UILabel new]; 380 | label.textColor = textColor; 381 | label.text = title; 382 | label.contentMode = UIViewContentModeCenter; 383 | label.textAlignment = NSTextAlignmentCenter; 384 | label.font = [UIFont systemFontOfSize:13]; 385 | 386 | return label; 387 | } 388 | 389 | - (void)_updateLabelWithTitle:(NSString *)title atIndex:(NSUInteger)index { 390 | UILabel *foregroundLabel = self.selectedLabels[index]; 391 | UILabel *backgroundLabel = self.labels[index]; 392 | 393 | foregroundLabel.text = title; 394 | backgroundLabel.text = title; 395 | } 396 | 397 | - (CGRect)_thumbRect { 398 | CGRect boundingRect = [self _thumbBoundingRect]; 399 | 400 | CGFloat width; 401 | if ([self numberOfSegments] > 0) { 402 | width = CGRectGetWidth(boundingRect) / [self numberOfSegments]; 403 | } else { 404 | width = CGRectGetWidth(boundingRect); 405 | } 406 | 407 | CGFloat height = CGRectGetHeight(boundingRect); 408 | 409 | return CGRectMake(boundingRect.origin.x, boundingRect.origin.y, width, 410 | height); 411 | } 412 | 413 | - (CGRect)_thumbBoundingRect { 414 | UIEdgeInsets insets = 415 | UIEdgeInsetsMake(self.thumbEdgeInset, 416 | self.thumbEdgeInset, 417 | self.thumbEdgeInset, 418 | self.thumbEdgeInset); 419 | CGRect thumbBoundingRect = UIEdgeInsetsInsetRect(self.bounds, insets); 420 | 421 | return thumbBoundingRect; 422 | } 423 | 424 | - (void)_moveThumbToSelectedSegment:(NSInteger)index animated:(BOOL)animated { 425 | 426 | CGRect newSelectionRect = [self _rectForSegmentAtIndex:index]; 427 | if (animated) { 428 | CGPoint fromCenter = (self.thumb.layer.presentationLayer 429 | ? self.thumb.layer.presentationLayer.position 430 | : self.thumb.center); 431 | CGPoint newCenter = [self _centerForSegmentAtIndex:index]; 432 | 433 | CABasicAnimation *thumbAnimation = [self _thumbUpdateAnimationWithFromCenter:fromCenter toCenter:newCenter]; 434 | [self.thumb.layer addAnimation:thumbAnimation forKey:@"basic"]; 435 | self.thumb.layer.position = newCenter; 436 | 437 | CABasicAnimation *maskAnimation = [self _thumbUpdateAnimationWithFromCenter:fromCenter toCenter:newCenter]; 438 | [self.thumbShowLayer.layer addAnimation:maskAnimation forKey:@"position"]; 439 | self.thumbShowLayer.layer.position = newCenter; 440 | } else { 441 | [self _moveThumbToNewFrame:newSelectionRect]; 442 | } 443 | } 444 | 445 | - (CABasicAnimation *)_thumbUpdateAnimationWithFromCenter:(CGPoint)fromCenter 446 | toCenter:(CGPoint)toCenter { 447 | CABasicAnimation *thumbAnimation = [CABasicAnimation animationWithKeyPath:@"position"]; 448 | thumbAnimation.fromValue = [NSValue valueWithCGPoint:fromCenter]; 449 | thumbAnimation.toValue = [NSValue valueWithCGPoint:toCenter]; 450 | thumbAnimation.duration = kNXTSegmentedControlDefaultAnimationDuration; 451 | thumbAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]; 452 | 453 | return thumbAnimation; 454 | } 455 | 456 | - (CGRect)_rectForSegmentAtIndex:(NSInteger)index { 457 | if (index < [self numberOfSegments]) { 458 | UILabel *segment = self.selectedLabels[index]; 459 | return segment.frame; 460 | } else { 461 | return CGRectZero; 462 | } 463 | } 464 | 465 | - (CGRect)_touchRectForSelectedSegment { 466 | return [self _touchRectForSegmentAtIndex:self.selectedSegmentIndex]; 467 | } 468 | 469 | - (CGRect)_touchRectForSegmentAtIndex:(NSInteger)index { 470 | if (index < [self numberOfSegments]) { 471 | UILabel *segment = self.selectedLabels[index]; 472 | CGRect touchRect = segment.frame; 473 | touchRect.origin.y = 0; 474 | touchRect.size.height = CGRectGetHeight(self.bounds); 475 | return touchRect; 476 | } else { 477 | return CGRectZero; 478 | } 479 | } 480 | 481 | - (CGPoint)_centerForSegmentAtIndex:(NSUInteger)index { 482 | if (index < [self numberOfSegments]) { 483 | UILabel *segment = self.selectedLabels[index]; 484 | return segment.center; 485 | } else { 486 | return CGPointZero; 487 | } 488 | } 489 | 490 | - (void)_updateLabels:(NSArray *)labels withAttributes:(NSDictionary *)attributes { 491 | for (UILabel *label in labels) { 492 | if (attributes[NSFontAttributeName]) { 493 | label.font = attributes[NSFontAttributeName]; 494 | } 495 | if (attributes[NSForegroundColorAttributeName]) { 496 | label.textColor = attributes[NSForegroundColorAttributeName]; 497 | } 498 | } 499 | } 500 | 501 | @end 502 | -------------------------------------------------------------------------------- /NXTSegmentedControlFramework/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.8 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSPrincipalClass 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /NXTSegmentedControlFramework/NXTSegmentedControlFramework.h: -------------------------------------------------------------------------------- 1 | // 2 | // NXTSegmentedControlFramework.h 3 | // NXTSegmentedControlFramework 4 | // 5 | // Created by Arkadiusz Holko on 10/10/2017. 6 | // Copyright © 2017 Patrick Mick. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "NXTSegmentedControl.h" 12 | 13 | //! Project version number for NXTSegmentedControlFramework. 14 | FOUNDATION_EXPORT double NXTSegmentedControlFrameworkVersionNumber; 15 | 16 | //! Project version string for NXTSegmentedControlFramework. 17 | FOUNDATION_EXPORT const unsigned char NXTSegmentedControlFrameworkVersionString[]; 18 | 19 | // In this header, you should import all the public headers of your framework using statements like #import 20 | 21 | 22 | -------------------------------------------------------------------------------- /NXTSegmentedControlTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.YayNext.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /NXTSegmentedControlTests/NXTSegmentedControlSnapshotTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // NXTSegmentedControlSnapshotTests.m 3 | // NXTSegmentedControl 4 | // 5 | // Created by Patrick Mick on 3/5/15. 6 | // Copyright (c) 2015 Patrick Mick. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | #import "NXTSegmentedControl.h" 13 | 14 | @interface NXTSegmentedControlSnapshotTests : FBSnapshotTestCase 15 | 16 | @end 17 | 18 | @implementation NXTSegmentedControlSnapshotTests 19 | 20 | - (void)setUp { 21 | [super setUp]; 22 | 23 | self.recordMode = NO; 24 | } 25 | 26 | - (void)testSegmentedControl_CreatedWithoutAFrame_ShouldProvideADefaultFrame { 27 | NXTSegmentedControl *segmentedControl = [[NXTSegmentedControl alloc] initWithItems:@[@"thing1", @"thing2"]]; 28 | FBSnapshotVerifyLayer(segmentedControl.layer, @"should provide a default frame"); 29 | } 30 | 31 | - (void)testSegementedControl_CreatedWithCustomFrame_ShouldRelayoutSubviews { 32 | NXTSegmentedControl *segmentedControl = [[NXTSegmentedControl alloc] initWithItems:@[@"test", @"test"]]; 33 | segmentedControl.frame = CGRectMake(0, 0, 100, 50); 34 | FBSnapshotVerifyLayer(segmentedControl.layer, @"should re-layout with a new frame"); 35 | } 36 | 37 | - (void)testSegmentedControl_ChangingTintColor_ShouldUpdateTheTrackColor { 38 | NXTSegmentedControl *segmentedControl = [[NXTSegmentedControl alloc] initWithItems:@[@"test", @"test"]]; 39 | segmentedControl.tintColor = [UIColor redColor]; 40 | FBSnapshotVerifyLayer(segmentedControl.layer, @"should tint the background when tint color is changed."); 41 | } 42 | 43 | - (void)testSegmentedControl_WithLongText_ShouldClipTheText { 44 | NXTSegmentedControl *segmentedControl = [[NXTSegmentedControl alloc] initWithItems:@[@"testtesttesttesttesttest", @"test"]]; 45 | FBSnapshotVerifyLayer(segmentedControl.layer, @"should tint the background when tint color is changed."); 46 | } 47 | 48 | - (void)testSegmentedControl_WithMoreThan2Segments_ShouldLayoutMultipleSegments { 49 | NXTSegmentedControl *segmentedControl = [[NXTSegmentedControl alloc] initWithItems:@[@"test", @"test", @"test"]]; 50 | FBSnapshotVerifyLayer(segmentedControl.layer, @"should display more than 2 segments correctly."); 51 | } 52 | 53 | - (void)testSegmentedControl_WithATonOfSegments_ShouldKeepTheLayoutLookingReasonable { 54 | NXTSegmentedControl *segmentedControl = [[NXTSegmentedControl alloc] initWithItems:@[@"test", @"test", @"test", @"test", @"test", @"test", @"test", @"test"]]; 55 | FBSnapshotVerifyLayer(segmentedControl.layer, @"should display a ton of segments reasonably."); 56 | } 57 | 58 | - (void)testSegmentedControl_WithSmallerThanNormalEdgeInsets_ShouldHaveASmallBorder { 59 | NXTSegmentedControl *segmentedControl = [[NXTSegmentedControl alloc] initWithItems:@[@"test", @"test"]]; 60 | segmentedControl.thumbEdgeInset = 1.0f; 61 | FBSnapshotVerifyLayer(segmentedControl.layer, @"should have a 1 pixel border around the thumb."); 62 | } 63 | 64 | - (void)testSegmentedControl_WithColoredThumb_ShouldSetTheThumbsBackgroundColor { 65 | NXTSegmentedControl *segmentedControl = [[NXTSegmentedControl alloc] initWithItems:@[@"test", @"test"]]; 66 | segmentedControl.thumbColor = [UIColor orangeColor]; 67 | FBSnapshotVerifyLayer(segmentedControl.layer, @"should have an orange thumb"); 68 | } 69 | 70 | - (void)testSegmentedControl_ChangingTitle_ShouldUpdateLabels { 71 | NXTSegmentedControl *segmentedControl = [[NXTSegmentedControl alloc] initWithItems:@[@"test", @"test"]]; 72 | [segmentedControl setTitle:@"updated title" forSegmentAtIndex:0]; 73 | FBSnapshotVerifyLayer(segmentedControl.layer, @"should update label text"); 74 | } 75 | 76 | - (void)testSegmentedControl_ChangingTitleTextAttributes_ShouldUpdateLabels_IncludingSelectedIfNotProvided { 77 | NXTSegmentedControl *segmentedControl = [[NXTSegmentedControl alloc] initWithItems:@[@"test", @"test"]]; 78 | [segmentedControl setTitleTextAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:20]} forState:UIControlStateNormal]; 79 | FBSnapshotVerifyLayer(segmentedControl.layer, @"should show bigger text"); 80 | } 81 | 82 | - (void)testSegmentedControl_ChangingSelectedTitleTextAttributes_ShouldUpdateSelectedLabels { 83 | NXTSegmentedControl *segmentedControl = [[NXTSegmentedControl alloc] initWithItems:@[@"test", @"test"]]; 84 | [segmentedControl setTitleTextAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:20]} forState:UIControlStateSelected]; 85 | FBSnapshotVerifyLayer(segmentedControl.layer, @"should show bigger text on selected label"); 86 | } 87 | 88 | - (void)testSegmentedControl_ChangingTitleTextAttributes_AfterChangingSelectedTitleTextAttributes_ShouldKeepOriginalSelectedAttributes { 89 | NXTSegmentedControl *segmentedControl = [[NXTSegmentedControl alloc] initWithItems:@[@"test", @"test"]]; 90 | [segmentedControl setTitleTextAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:20]} forState:UIControlStateSelected]; 91 | [segmentedControl setTitleTextAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:8]} forState:UIControlStateNormal]; 92 | FBSnapshotVerifyLayer(segmentedControl.layer, @"should still bigger text under selection thumb"); 93 | } 94 | 95 | - (void)testInheritingGlobalTintColor { 96 | UIWindow *window = [UIWindow new]; 97 | window.tintColor = [UIColor purpleColor]; 98 | 99 | NXTSegmentedControl *segmentedControl = [[NXTSegmentedControl alloc] initWithItems:@[@"test", @"test"]]; 100 | [window addSubview:segmentedControl]; 101 | FBSnapshotVerifyLayer(segmentedControl.layer, @"should be tinted correctly"); 102 | } 103 | 104 | - (void)testSettingSelectedIndexShouldMoveTheThumb { 105 | NXTSegmentedControl *segmentedControl = [[NXTSegmentedControl alloc] initWithItems:@[@"thing1", @"thing2"]]; 106 | [segmentedControl setSelectedSegmentIndex:1 animated:NO]; 107 | FBSnapshotVerifyLayer(segmentedControl.layer, @"thumb should be over second segment"); 108 | } 109 | 110 | - (void)testChangingTheFrameShouldKeepTheSelectedIndex { 111 | NXTSegmentedControl *segmentedControl = [[NXTSegmentedControl alloc] initWithItems:@[@"thing1", @"thing2"]]; 112 | [segmentedControl setSelectedSegmentIndex:1 animated:NO]; 113 | segmentedControl.frame = CGRectMake(0, 0, 150, 40); 114 | FBSnapshotVerifyLayer(segmentedControl.layer, @"thumb should be over second segment"); 115 | } 116 | 117 | @end 118 | -------------------------------------------------------------------------------- /NXTSegmentedControlTests/NXTSegmentedControlTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // NXTSegmentedControlTests.m 3 | // NXTSegmentedControlTests 4 | // 5 | // Created by Patrick Mick on 3/5/15. 6 | // Copyright (c) 2015 Patrick Mick. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "NXTSegmentedControl.h" 12 | 13 | @interface NXTSegmentedControlTests : XCTestCase 14 | 15 | @end 16 | 17 | @implementation NXTSegmentedControlTests 18 | 19 | - (void)testGettingTheFirstTitle { 20 | NXTSegmentedControl *segmentedControl = [[NXTSegmentedControl alloc] initWithItems:@[@"thing1", @"thing2"]]; 21 | NSString *title = [segmentedControl titleForSegmentAtIndex:0]; 22 | XCTAssert([title isEqualToString:@"thing1"]); 23 | } 24 | 25 | - (void)testGettingTheSecondTitle { 26 | NXTSegmentedControl *segmentedControl = [[NXTSegmentedControl alloc] initWithItems:@[@"thing1", @"thing2"]]; 27 | NSString *title = [segmentedControl titleForSegmentAtIndex:1]; 28 | XCTAssert([title isEqualToString:@"thing2"]); 29 | } 30 | 31 | - (void)testChangingATitle { 32 | NXTSegmentedControl *segmentedControl = [[NXTSegmentedControl alloc] initWithItems:@[@"thing1", @"thing2"]]; 33 | [segmentedControl setTitle:@"changedTitle" forSegmentAtIndex:0]; 34 | NSString *title = [segmentedControl titleForSegmentAtIndex:0]; 35 | XCTAssert([title isEqualToString:@"changedTitle"]); 36 | } 37 | 38 | - (void)testTitleTextAttributes { 39 | NXTSegmentedControl *segmentedControl = [[NXTSegmentedControl alloc] initWithItems:@[@"thing1", @"thing2"]]; 40 | XCTAssertNil([segmentedControl titleTextAttributesForState:UIControlStateNormal]); 41 | 42 | NSDictionary *someAttributes = @{NSFontAttributeName: [UIFont systemFontOfSize:12]}; 43 | [segmentedControl setTitleTextAttributes:someAttributes forState:UIControlStateNormal]; 44 | XCTAssertEqual(someAttributes, [segmentedControl titleTextAttributesForState:UIControlStateNormal]); 45 | 46 | NSDictionary *selectedAttributes = @{NSFontAttributeName: [UIFont boldSystemFontOfSize:12], 47 | NSForegroundColorAttributeName: [UIColor darkGrayColor] 48 | }; 49 | [segmentedControl setTitleTextAttributes:selectedAttributes forState:UIControlStateSelected]; 50 | XCTAssertEqual(selectedAttributes, [segmentedControl titleTextAttributesForState:UIControlStateSelected]); 51 | } 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /NXTSegmentedControlTests/ReferenceImages_64/NXTSegmentedControlSnapshotTests/testChangingTheFrameShouldKeepTheSelectedIndex_thumb should be over second segment@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmick/NXTSegmentedControl/a1af98755e165ef37810646da1b1e1278c7a3b27/NXTSegmentedControlTests/ReferenceImages_64/NXTSegmentedControlSnapshotTests/testChangingTheFrameShouldKeepTheSelectedIndex_thumb should be over second segment@2x.png -------------------------------------------------------------------------------- /NXTSegmentedControlTests/ReferenceImages_64/NXTSegmentedControlSnapshotTests/testInheritingGlobalTintColor_should be tinted correctly@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmick/NXTSegmentedControl/a1af98755e165ef37810646da1b1e1278c7a3b27/NXTSegmentedControlTests/ReferenceImages_64/NXTSegmentedControlSnapshotTests/testInheritingGlobalTintColor_should be tinted correctly@2x.png -------------------------------------------------------------------------------- /NXTSegmentedControlTests/ReferenceImages_64/NXTSegmentedControlSnapshotTests/testSegementedControl_CreatedWithCustomFrame_ShouldRelayoutSubviews_should re-layout with a new frame@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmick/NXTSegmentedControl/a1af98755e165ef37810646da1b1e1278c7a3b27/NXTSegmentedControlTests/ReferenceImages_64/NXTSegmentedControlSnapshotTests/testSegementedControl_CreatedWithCustomFrame_ShouldRelayoutSubviews_should re-layout with a new frame@2x.png -------------------------------------------------------------------------------- /NXTSegmentedControlTests/ReferenceImages_64/NXTSegmentedControlSnapshotTests/testSegmentedControl_ChangingSelectedTitleTextAttributes_ShouldUpdateSelectedLabels_should show bigger text on selected label@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmick/NXTSegmentedControl/a1af98755e165ef37810646da1b1e1278c7a3b27/NXTSegmentedControlTests/ReferenceImages_64/NXTSegmentedControlSnapshotTests/testSegmentedControl_ChangingSelectedTitleTextAttributes_ShouldUpdateSelectedLabels_should show bigger text on selected label@2x.png -------------------------------------------------------------------------------- /NXTSegmentedControlTests/ReferenceImages_64/NXTSegmentedControlSnapshotTests/testSegmentedControl_ChangingTintColor_ShouldUpdateTheTrackColor_should tint the background when tint color is changed.@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmick/NXTSegmentedControl/a1af98755e165ef37810646da1b1e1278c7a3b27/NXTSegmentedControlTests/ReferenceImages_64/NXTSegmentedControlSnapshotTests/testSegmentedControl_ChangingTintColor_ShouldUpdateTheTrackColor_should tint the background when tint color is changed.@2x.png -------------------------------------------------------------------------------- /NXTSegmentedControlTests/ReferenceImages_64/NXTSegmentedControlSnapshotTests/testSegmentedControl_ChangingTitleTextAttributes_AfterChangingSelectedTitleTextAttributes_ShouldKeepOriginalSelectedAttributes_should still bigger text under selection thumb@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmick/NXTSegmentedControl/a1af98755e165ef37810646da1b1e1278c7a3b27/NXTSegmentedControlTests/ReferenceImages_64/NXTSegmentedControlSnapshotTests/testSegmentedControl_ChangingTitleTextAttributes_AfterChangingSelectedTitleTextAttributes_ShouldKeepOriginalSelectedAttributes_should still bigger text under selection thumb@2x.png -------------------------------------------------------------------------------- /NXTSegmentedControlTests/ReferenceImages_64/NXTSegmentedControlSnapshotTests/testSegmentedControl_ChangingTitleTextAttributes_ShouldUpdateLabels_IncludingSelectedIfNotProvided_should show bigger text@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmick/NXTSegmentedControl/a1af98755e165ef37810646da1b1e1278c7a3b27/NXTSegmentedControlTests/ReferenceImages_64/NXTSegmentedControlSnapshotTests/testSegmentedControl_ChangingTitleTextAttributes_ShouldUpdateLabels_IncludingSelectedIfNotProvided_should show bigger text@2x.png -------------------------------------------------------------------------------- /NXTSegmentedControlTests/ReferenceImages_64/NXTSegmentedControlSnapshotTests/testSegmentedControl_ChangingTitle_ShouldUpdateLabels_should update label text@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmick/NXTSegmentedControl/a1af98755e165ef37810646da1b1e1278c7a3b27/NXTSegmentedControlTests/ReferenceImages_64/NXTSegmentedControlSnapshotTests/testSegmentedControl_ChangingTitle_ShouldUpdateLabels_should update label text@2x.png -------------------------------------------------------------------------------- /NXTSegmentedControlTests/ReferenceImages_64/NXTSegmentedControlSnapshotTests/testSegmentedControl_CreatedWithoutAFrame_ShouldProvideADefaultFrame_should provide a default frame@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmick/NXTSegmentedControl/a1af98755e165ef37810646da1b1e1278c7a3b27/NXTSegmentedControlTests/ReferenceImages_64/NXTSegmentedControlSnapshotTests/testSegmentedControl_CreatedWithoutAFrame_ShouldProvideADefaultFrame_should provide a default frame@2x.png -------------------------------------------------------------------------------- /NXTSegmentedControlTests/ReferenceImages_64/NXTSegmentedControlSnapshotTests/testSegmentedControl_WithATonOfSegments_ShouldKeepTheLayoutLookingReasonable_should display a ton of segments reasonably.@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmick/NXTSegmentedControl/a1af98755e165ef37810646da1b1e1278c7a3b27/NXTSegmentedControlTests/ReferenceImages_64/NXTSegmentedControlSnapshotTests/testSegmentedControl_WithATonOfSegments_ShouldKeepTheLayoutLookingReasonable_should display a ton of segments reasonably.@2x.png -------------------------------------------------------------------------------- /NXTSegmentedControlTests/ReferenceImages_64/NXTSegmentedControlSnapshotTests/testSegmentedControl_WithColoredThumb_ShouldSetTheThumbsBackgroundColor_should have an orange thumb@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmick/NXTSegmentedControl/a1af98755e165ef37810646da1b1e1278c7a3b27/NXTSegmentedControlTests/ReferenceImages_64/NXTSegmentedControlSnapshotTests/testSegmentedControl_WithColoredThumb_ShouldSetTheThumbsBackgroundColor_should have an orange thumb@2x.png -------------------------------------------------------------------------------- /NXTSegmentedControlTests/ReferenceImages_64/NXTSegmentedControlSnapshotTests/testSegmentedControl_WithLongText_ShouldClipTheText_should tint the background when tint color is changed.@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmick/NXTSegmentedControl/a1af98755e165ef37810646da1b1e1278c7a3b27/NXTSegmentedControlTests/ReferenceImages_64/NXTSegmentedControlSnapshotTests/testSegmentedControl_WithLongText_ShouldClipTheText_should tint the background when tint color is changed.@2x.png -------------------------------------------------------------------------------- /NXTSegmentedControlTests/ReferenceImages_64/NXTSegmentedControlSnapshotTests/testSegmentedControl_WithMoreThan2Segments_ShouldLayoutMultipleSegments_should display more than 2 segments correctly.@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmick/NXTSegmentedControl/a1af98755e165ef37810646da1b1e1278c7a3b27/NXTSegmentedControlTests/ReferenceImages_64/NXTSegmentedControlSnapshotTests/testSegmentedControl_WithMoreThan2Segments_ShouldLayoutMultipleSegments_should display more than 2 segments correctly.@2x.png -------------------------------------------------------------------------------- /NXTSegmentedControlTests/ReferenceImages_64/NXTSegmentedControlSnapshotTests/testSegmentedControl_WithSmallerThanNormalEdgeInsets_ShouldHaveASmallBorder_should have a 1 pixel border around the thumb.@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmick/NXTSegmentedControl/a1af98755e165ef37810646da1b1e1278c7a3b27/NXTSegmentedControlTests/ReferenceImages_64/NXTSegmentedControlSnapshotTests/testSegmentedControl_WithSmallerThanNormalEdgeInsets_ShouldHaveASmallBorder_should have a 1 pixel border around the thumb.@2x.png -------------------------------------------------------------------------------- /NXTSegmentedControlTests/ReferenceImages_64/NXTSegmentedControlSnapshotTests/testSettingSelectedIndexShouldMoveTheThumb_thumb should be over second segment@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmick/NXTSegmentedControl/a1af98755e165ef37810646da1b1e1278c7a3b27/NXTSegmentedControlTests/ReferenceImages_64/NXTSegmentedControlSnapshotTests/testSettingSelectedIndexShouldMoveTheThumb_thumb should be over second segment@2x.png -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | source 'https://github.com/CocoaPods/Specs.git' 2 | platform :ios, '8.0' 3 | 4 | target 'NXTSegmentedControl' do 5 | target 'NXTSegmentedControlTests' do 6 | inherit! :search_paths 7 | pod 'FBSnapshotTestCase', '1.8.1' 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - FBSnapshotTestCase (1.8.1) 3 | 4 | DEPENDENCIES: 5 | - FBSnapshotTestCase (= 1.8.1) 6 | 7 | SPEC CHECKSUMS: 8 | FBSnapshotTestCase: 3dc3899168747a0319c5278f5b3445c13a6532dd 9 | 10 | PODFILE CHECKSUM: caced43233af7417c4f4c25f3587f84fb342194b 11 | 12 | COCOAPODS: 1.1.0.rc.2 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NXTSegmentedControl 2 | 3 | ![Pod Version](https://cocoapod-badges.herokuapp.com/v/NXTSegmentedControl/badge.png) ![Travis Status](https://travis-ci.org/YayNext/NXTSegmentedControl.svg?branch=master) 4 | 5 | The styled swipeable segmented control used in Next 6 | 7 | ![NXTSegmentedControl](https://raw.githubusercontent.com/YayNext/NXTSegmentedControl/master/images/demo.gif) 8 | 9 | 10 | ## Installation 11 | 12 | 13 | Either manually add the NXTSegmentedControl.h/m files to your project, or add the NXTSegmentedControl cocoapod by adding the following line to your podfile: 14 | 15 | 16 | ``` 17 | pod 'NXTSegmentedControl' 18 | ``` 19 | 20 | ## Usage 21 | 22 | Start by importing the header. 23 | 24 | ```objective-c 25 | #import 26 | ``` 27 | 28 | Create the segmented control, and customize the appearance. 29 | 30 | ```objective-c 31 | NXTSegmentedControl *segmentedControl = [[NXTSegmentedControl alloc] initWithItems:@[@"Post", @"Comments"]]; 32 | segmentedControl.tintColor = [UIColor redColor]; 33 | [segmentedControl addTarget:self action:@selector(segmentedControlValueChanged:) forControlEvents:UIControlEventValueChanged]; 34 | [self.view addSubview: segmentedControl]; 35 | ``` 36 | Finally implement your action method. 37 | 38 | ```objective-c 39 | - (void)segmentedControlValueChanged:(id)sender { 40 | NXTSegmentedControl *segmentedControl = (NXTSegmentedControl *)sender; 41 | NSString *t = [NSString stringWithFormat:@"%d", segmentedControl.selectedSegmentIndex]; 42 | NSLog(t); 43 | } 44 | ``` 45 | 46 | NXTSegmentedControl uses the target action pattern just like most controls from UIKit. This creation code should be nearly identical to UISegmentedControl creation. 47 | -------------------------------------------------------------------------------- /images/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmick/NXTSegmentedControl/a1af98755e165ef37810646da1b1e1278c7a3b27/images/demo.gif -------------------------------------------------------------------------------- /module.modulemap: -------------------------------------------------------------------------------- 1 | module NXTSegmentedControlFramework { 2 | umbrella header "Headers/NXTSegmentedControlFramework.h" 3 | requires objc_arc 4 | } 5 | 6 | --------------------------------------------------------------------------------