├── FWSegmentedControl.podspec ├── FWSegmentedControl └── FWSegmentedControl.swift ├── FWSegmentedControlOCDemo ├── FWSegmentedControl-Bridging-Header.h ├── FWSegmentedControl.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── xcshareddata │ │ └── xcschemes │ │ │ └── FWSegmentedControl.xcscheme │ └── xcuserdata │ │ └── xfg.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── FWSegmentedControl.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── FWSegmentedControl │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ │ ├── 1-selected.imageset │ │ │ ├── 1-selected@2x.png │ │ │ ├── 1-selected@3x.png │ │ │ └── Contents.json │ │ ├── 1.imageset │ │ │ ├── 1@2x.png │ │ │ ├── 1@3x.png │ │ │ └── Contents.json │ │ ├── 2-selected.imageset │ │ │ ├── 2-selected@2x.png │ │ │ ├── 2-selected@3x.png │ │ │ └── Contents.json │ │ ├── 2.imageset │ │ │ ├── 2@2x.png │ │ │ ├── 2@3x.png │ │ │ └── Contents.json │ │ ├── 3-selected.imageset │ │ │ ├── 3-selected@2x.png │ │ │ ├── 3-selected@3x.png │ │ │ └── Contents.json │ │ ├── 3.imageset │ │ │ ├── 3@2x.png │ │ │ ├── 3@3x.png │ │ │ └── Contents.json │ │ ├── 4-selected.imageset │ │ │ ├── 4-selected@2x.png │ │ │ ├── 4-selected@3x.png │ │ │ └── Contents.json │ │ ├── 4.imageset │ │ │ ├── 4@2x.png │ │ │ ├── 4@3x.png │ │ │ └── Contents.json │ │ ├── 5-selected.imageset │ │ │ ├── 5-selected@2x.png │ │ │ ├── 5-selected@3x.png │ │ │ └── Contents.json │ │ ├── 5.imageset │ │ │ ├── 5@2x.png │ │ │ ├── 5@3x.png │ │ │ └── Contents.json │ │ ├── 6-selected.imageset │ │ │ ├── 6-selected@2x.png │ │ │ ├── 6-selected@3x.png │ │ │ └── Contents.json │ │ ├── 6.imageset │ │ │ ├── 6@2x.png │ │ │ ├── 6@3x.png │ │ │ └── Contents.json │ │ ├── 7-selected.imageset │ │ │ ├── 7-selected@2x.png │ │ │ ├── 7-selected@3x.png │ │ │ └── Contents.json │ │ ├── 7.imageset │ │ │ ├── 7@2x.png │ │ │ ├── 7@3x.png │ │ │ └── Contents.json │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── Contents.json │ │ ├── a-selected.imageset │ │ │ ├── Contents.json │ │ │ ├── a-selected@2x.png │ │ │ └── a-selected@3x.png │ │ ├── a.imageset │ │ │ ├── Contents.json │ │ │ ├── a@2x.png │ │ │ └── a@3x.png │ │ ├── b-selected.imageset │ │ │ ├── Contents.json │ │ │ ├── b-selected@2x.png │ │ │ └── b-selected@3x.png │ │ ├── b.imageset │ │ │ ├── Contents.json │ │ │ ├── b@2x.png │ │ │ └── b@3x.png │ │ ├── c-selected.imageset │ │ │ ├── Contents.json │ │ │ ├── c-selected@2x.png │ │ │ └── c-selected@3x.png │ │ ├── c.imageset │ │ │ ├── Contents.json │ │ │ ├── c@2x.png │ │ │ └── c@3x.png │ │ ├── hm_hot_city.imageset │ │ │ ├── Contents.json │ │ │ ├── hm_hot_city@2x.png │ │ │ └── hm_hot_city@3x.png │ │ └── hm_hot_city_selected.imageset │ │ │ ├── Contents.json │ │ │ ├── hm_hot_city_selected@2x.png │ │ │ └── hm_hot_city_selected@3x.png │ ├── Base.lproj │ │ └── LaunchScreen.storyboard │ ├── FWNavigationController.h │ ├── FWNavigationController.m │ ├── Info.plist │ ├── ViewController.h │ ├── ViewController.m │ ├── ViewController2.h │ ├── ViewController2.m │ └── main.m ├── FWSegmentedControlTests │ ├── FWSegmentedControlTests.m │ └── Info.plist ├── FWSegmentedControlUITests │ ├── FWSegmentedControlUITests.m │ └── Info.plist ├── Podfile ├── Podfile.lock ├── Pods │ ├── FWSegmentedControl │ │ ├── FWSegmentedControl │ │ │ └── FWSegmentedControl │ │ │ │ └── FWSegmentedControl │ │ │ │ └── FWSegmentedControl.swift │ │ └── README.md │ ├── Manifest.lock │ ├── Pods.xcodeproj │ │ ├── project.pbxproj │ │ └── xcuserdata │ │ │ ├── xfg.xcuserdatad │ │ │ └── xcschemes │ │ │ │ ├── FWSegmentedControl.xcscheme │ │ │ │ ├── Pods-FWSegmentedControl.xcscheme │ │ │ │ └── xcschememanagement.plist │ │ │ └── yechen.xcuserdatad │ │ │ └── xcschemes │ │ │ ├── FWSegmentedControl.xcscheme │ │ │ └── Pods-FWSegmentedControl.xcscheme │ └── Target Support Files │ │ ├── FWSegmentedControl │ │ ├── FWSegmentedControl-Info.plist │ │ ├── FWSegmentedControl-dummy.m │ │ ├── FWSegmentedControl-prefix.pch │ │ ├── FWSegmentedControl-umbrella.h │ │ ├── FWSegmentedControl.modulemap │ │ └── FWSegmentedControl.xcconfig │ │ └── Pods-FWSegmentedControl │ │ ├── Info.plist │ │ ├── Pods-FWSegmentedControl-Info.plist │ │ ├── Pods-FWSegmentedControl-acknowledgements.markdown │ │ ├── Pods-FWSegmentedControl-acknowledgements.plist │ │ ├── Pods-FWSegmentedControl-dummy.m │ │ ├── Pods-FWSegmentedControl-frameworks.sh │ │ ├── Pods-FWSegmentedControl-resources.sh │ │ ├── Pods-FWSegmentedControl-umbrella.h │ │ ├── Pods-FWSegmentedControl.debug.xcconfig │ │ ├── Pods-FWSegmentedControl.modulemap │ │ └── Pods-FWSegmentedControl.release.xcconfig └── Test.swift ├── FWSegmentedControlSwiftDemo ├── FWSegmentedControl.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── xcuserdata │ │ ├── xfg.xcuserdatad │ │ ├── xcdebugger │ │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ │ └── xcschememanagement.plist │ │ └── yechen.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ ├── FWSegmentedControl.xcscheme │ │ └── xcschememanagement.plist ├── FWSegmentedControl │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ ├── 1-selected.imageset │ │ │ ├── 1-selected@2x.png │ │ │ ├── 1-selected@3x.png │ │ │ └── Contents.json │ │ ├── 1.imageset │ │ │ ├── 1@2x.png │ │ │ ├── 1@3x.png │ │ │ └── Contents.json │ │ ├── 2-selected.imageset │ │ │ ├── 2-selected@2x.png │ │ │ ├── 2-selected@3x.png │ │ │ └── Contents.json │ │ ├── 2.imageset │ │ │ ├── 2@2x.png │ │ │ ├── 2@3x.png │ │ │ └── Contents.json │ │ ├── 3-selected.imageset │ │ │ ├── 3-selected@2x.png │ │ │ ├── 3-selected@3x.png │ │ │ └── Contents.json │ │ ├── 3.imageset │ │ │ ├── 3@2x.png │ │ │ ├── 3@3x.png │ │ │ └── Contents.json │ │ ├── 4-selected.imageset │ │ │ ├── 4-selected@2x.png │ │ │ ├── 4-selected@3x.png │ │ │ └── Contents.json │ │ ├── 4.imageset │ │ │ ├── 4@2x.png │ │ │ ├── 4@3x.png │ │ │ └── Contents.json │ │ ├── 5-selected.imageset │ │ │ ├── 5-selected@2x.png │ │ │ ├── 5-selected@3x.png │ │ │ └── Contents.json │ │ ├── 5.imageset │ │ │ ├── 5@2x.png │ │ │ ├── 5@3x.png │ │ │ └── Contents.json │ │ ├── 6-selected.imageset │ │ │ ├── 6-selected@2x.png │ │ │ ├── 6-selected@3x.png │ │ │ └── Contents.json │ │ ├── 6.imageset │ │ │ ├── 6@2x.png │ │ │ ├── 6@3x.png │ │ │ └── Contents.json │ │ ├── 7-selected.imageset │ │ │ ├── 7-selected@2x.png │ │ │ ├── 7-selected@3x.png │ │ │ └── Contents.json │ │ ├── 7.imageset │ │ │ ├── 7@2x.png │ │ │ ├── 7@3x.png │ │ │ └── Contents.json │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── Contents.json │ │ ├── a-selected.imageset │ │ │ ├── Contents.json │ │ │ ├── a-selected@2x.png │ │ │ └── a-selected@3x.png │ │ ├── a.imageset │ │ │ ├── Contents.json │ │ │ ├── a@2x.png │ │ │ └── a@3x.png │ │ ├── b-selected.imageset │ │ │ ├── Contents.json │ │ │ ├── b-selected@2x.png │ │ │ └── b-selected@3x.png │ │ ├── b.imageset │ │ │ ├── Contents.json │ │ │ ├── b@2x.png │ │ │ └── b@3x.png │ │ ├── c-selected.imageset │ │ │ ├── Contents.json │ │ │ ├── c-selected@2x.png │ │ │ └── c-selected@3x.png │ │ ├── c.imageset │ │ │ ├── Contents.json │ │ │ ├── c@2x.png │ │ │ └── c@3x.png │ │ ├── hm_hot_city.imageset │ │ │ ├── Contents.json │ │ │ ├── hm_hot_city@2x.png │ │ │ └── hm_hot_city@3x.png │ │ └── hm_hot_city_selected.imageset │ │ │ ├── Contents.json │ │ │ ├── hm_hot_city_selected@2x.png │ │ │ └── hm_hot_city_selected@3x.png │ ├── Base.lproj │ │ └── LaunchScreen.storyboard │ ├── FWNavigationController.swift │ ├── Info.plist │ ├── NewsViewController.swift │ ├── ShoppingViewController.swift │ ├── ViewController.swift │ └── ViewController2.swift ├── FWSegmentedControlTests │ ├── FWSegmentedControlTests.swift │ └── Info.plist └── FWSegmentedControlUITests │ ├── FWSegmentedControlUITests.swift │ └── Info.plist ├── LICENSE ├── README.md └── 效果 ├── FWSegmentedControl.png ├── 示例1.gif ├── 示例2.gif └── 设置1.jpg /FWSegmentedControl.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod spec lint FWSegmentedControl.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 | 11 | # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 12 | # 13 | # These will help people to find your library, and whilst it 14 | # can feel like a chore to fill in it's definitely to your advantage. The 15 | # summary should be tweet-length, and the description more in depth. 16 | # 17 | 18 | s.name = "FWSegmentedControl" 19 | s.version = "2.3.3" 20 | s.summary = "滑动分段控制,多样式、灵活、便利是其最大的优势。" 21 | 22 | # This description is used to generate tags and improve search results. 23 | # * Think: What does it do? Why did you write it? What is the focus? 24 | # * Try to keep it short, snappy and to the point. 25 | # * Write the description between the DESC delimiters below. 26 | # * Finally, don't worry about the indent, CocoaPods strips it! 27 | s.description = <<-DESC 28 | FWSegmentedControl兼容OC,借鉴了前辈项目:HMSegmentedControl,在此非常感谢前辈的分享 29 | DESC 30 | 31 | s.homepage = "https://github.com/choiceyou/FWSegmentedControl" 32 | # s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif" 33 | 34 | 35 | # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 36 | # 37 | # Licensing your code is important. See http://choosealicense.com for more info. 38 | # CocoaPods will detect a license file if there is a named LICENSE* 39 | # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'. 40 | # 41 | 42 | s.license = "MIT" 43 | # s.license = { :type => "MIT", :file => "FILE_LICENSE" } 44 | 45 | 46 | # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 47 | # 48 | # Specify the authors of the library, with email addresses. Email addresses 49 | # of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also 50 | # accepts just a name if you'd rather not provide an email address. 51 | # 52 | # Specify a social_media_url where others can refer to, for example a twitter 53 | # profile URL. 54 | # 55 | 56 | s.author = { "xfg" => "853299701@qq.com" } 57 | # Or just: s.author = "xfg" 58 | # s.authors = { "xfg" => "853299701@qq.com" } 59 | # s.social_media_url = "http://twitter.com/xfg" 60 | 61 | # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 62 | # 63 | # If this Pod runs only on iOS or OS X, then specify the platform and 64 | # the deployment target. You can optionally include the target after the platform. 65 | # 66 | 67 | s.swift_version = "5.0" 68 | s.platform = :ios, "8.0" 69 | 70 | # When using multiple platforms 71 | # s.ios.deployment_target = "5.0" 72 | # s.osx.deployment_target = "10.7" 73 | # s.watchos.deployment_target = "2.0" 74 | # s.tvos.deployment_target = "9.0" 75 | 76 | 77 | # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 78 | # 79 | # Specify the location from where the source should be retrieved. 80 | # Supports git, hg, bzr, svn and HTTP. 81 | # 82 | 83 | s.source = { :git => "https://github.com/choiceyou/FWSegmentedControl.git", :tag => "#{s.version}" } 84 | 85 | 86 | # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 87 | # 88 | # CocoaPods is smart about how it includes source code. For source files 89 | # giving a folder will include any swift, h, m, mm, c & cpp files. 90 | # For header files it will include any header in the folder. 91 | # Not including the public_header_files will make all headers public. 92 | # 93 | 94 | s.source_files = "FWSegmentedControl", "FWSegmentedControl/**/*.swift" 95 | 96 | # s.exclude_files = "Classes/Exclude" 97 | # s.public_header_files = "Classes/**/*.h" 98 | 99 | 100 | # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 101 | # 102 | # A list of resources included with the Pod. These are copied into the 103 | # target bundle with a build phase script. Anything else will be cleaned. 104 | # You can preserve files from being cleaned, please don't preserve 105 | # non-essential files like tests, examples and documentation. 106 | # 107 | 108 | # s.resource = "icon.png" 109 | # s.resources = "Resources/*.png" 110 | 111 | # s.preserve_paths = "FilesToSave", "MoreFilesToSave" 112 | 113 | 114 | # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 115 | # 116 | # Link your library with frameworks, or libraries. Libraries do not include 117 | # the lib prefix of their name. 118 | # 119 | 120 | # s.framework = "SomeFramework" 121 | s.frameworks = "UIKit", "Foundation" 122 | 123 | # s.library = "iconv" 124 | # s.libraries = "iconv", "xml2" 125 | 126 | 127 | # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 128 | # 129 | # If your library depends on compiler flags you can set them in the xcconfig hash 130 | # where they will only apply to your library. If you depend on other Podspecs 131 | # you can include multiple dependencies to ensure it works. 132 | 133 | s.requires_arc = true 134 | 135 | # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" } 136 | # s.dependency "JSONKit", "~> 1.4" 137 | 138 | end 139 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | 5 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl.xcodeproj/xcshareddata/xcschemes/FWSegmentedControl.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 45 | 51 | 52 | 53 | 54 | 60 | 62 | 68 | 69 | 70 | 71 | 73 | 74 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl.xcodeproj/xcuserdata/xfg.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | FWSegmentedControl.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 2 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 496899C2205B7173009F43E5 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // FWSegmentedControl 4 | // 5 | // Created by xfg on 2018/3/16. 6 | // Copyright © 2018年 xfg. 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 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // FWSegmentedControl 4 | // 5 | // Created by xfg on 2018/3/16. 6 | // Copyright © 2018年 xfg. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "ViewController.h" 11 | #import "FWNavigationController.h" 12 | 13 | @interface AppDelegate () 14 | 15 | @end 16 | 17 | @implementation AppDelegate 18 | 19 | 20 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 21 | // Override point for customization after application launch. 22 | 23 | self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds]; 24 | self.window.rootViewController = [[FWNavigationController alloc] initWithRootViewController:[[ViewController alloc] init]]; 25 | [self.window makeKeyAndVisible]; 26 | 27 | return YES; 28 | } 29 | 30 | 31 | - (void)applicationWillResignActive:(UIApplication *)application { 32 | // 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. 33 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 34 | } 35 | 36 | 37 | - (void)applicationDidEnterBackground:(UIApplication *)application { 38 | // 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. 39 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 40 | } 41 | 42 | 43 | - (void)applicationWillEnterForeground:(UIApplication *)application { 44 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 45 | } 46 | 47 | 48 | - (void)applicationDidBecomeActive:(UIApplication *)application { 49 | // 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. 50 | } 51 | 52 | 53 | - (void)applicationWillTerminate:(UIApplication *)application { 54 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 55 | } 56 | 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/1-selected.imageset/1-selected@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/1-selected.imageset/1-selected@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/1-selected.imageset/1-selected@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/1-selected.imageset/1-selected@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/1-selected.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "1-selected@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "1-selected@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/1.imageset/1@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/1.imageset/1@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/1.imageset/1@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/1.imageset/1@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/1.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "1@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "1@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/2-selected.imageset/2-selected@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/2-selected.imageset/2-selected@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/2-selected.imageset/2-selected@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/2-selected.imageset/2-selected@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/2-selected.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "2-selected@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "2-selected@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/2.imageset/2@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/2.imageset/2@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/2.imageset/2@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/2.imageset/2@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/2.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "2@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "2@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/3-selected.imageset/3-selected@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/3-selected.imageset/3-selected@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/3-selected.imageset/3-selected@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/3-selected.imageset/3-selected@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/3-selected.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "3-selected@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "3-selected@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/3.imageset/3@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/3.imageset/3@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/3.imageset/3@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/3.imageset/3@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/3.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "3@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "3@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/4-selected.imageset/4-selected@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/4-selected.imageset/4-selected@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/4-selected.imageset/4-selected@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/4-selected.imageset/4-selected@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/4-selected.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "4-selected@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "4-selected@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/4.imageset/4@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/4.imageset/4@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/4.imageset/4@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/4.imageset/4@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/4.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "4@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "4@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/5-selected.imageset/5-selected@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/5-selected.imageset/5-selected@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/5-selected.imageset/5-selected@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/5-selected.imageset/5-selected@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/5-selected.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "5-selected@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "5-selected@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/5.imageset/5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/5.imageset/5@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/5.imageset/5@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/5.imageset/5@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/5.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "5@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "5@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/6-selected.imageset/6-selected@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/6-selected.imageset/6-selected@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/6-selected.imageset/6-selected@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/6-selected.imageset/6-selected@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/6-selected.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "6-selected@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "6-selected@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/6.imageset/6@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/6.imageset/6@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/6.imageset/6@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/6.imageset/6@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/6.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "6@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "6@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/7-selected.imageset/7-selected@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/7-selected.imageset/7-selected@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/7-selected.imageset/7-selected@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/7-selected.imageset/7-selected@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/7-selected.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "7-selected@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "7-selected@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/7.imageset/7@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/7.imageset/7@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/7.imageset/7@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/7.imageset/7@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/7.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "7@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "7@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/a-selected.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "a-selected@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "a-selected@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/a-selected.imageset/a-selected@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/a-selected.imageset/a-selected@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/a-selected.imageset/a-selected@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/a-selected.imageset/a-selected@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/a.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "a@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "a@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/a.imageset/a@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/a.imageset/a@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/a.imageset/a@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/a.imageset/a@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/b-selected.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "b-selected@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "b-selected@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/b-selected.imageset/b-selected@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/b-selected.imageset/b-selected@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/b-selected.imageset/b-selected@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/b-selected.imageset/b-selected@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/b.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "b@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "b@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/b.imageset/b@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/b.imageset/b@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/b.imageset/b@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/b.imageset/b@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/c-selected.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "c-selected@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "c-selected@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/c-selected.imageset/c-selected@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/c-selected.imageset/c-selected@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/c-selected.imageset/c-selected@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/c-selected.imageset/c-selected@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/c.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "c@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "c@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/c.imageset/c@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/c.imageset/c@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/c.imageset/c@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/c.imageset/c@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/hm_hot_city.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "hm_hot_city@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "hm_hot_city@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/hm_hot_city.imageset/hm_hot_city@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/hm_hot_city.imageset/hm_hot_city@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/hm_hot_city.imageset/hm_hot_city@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/hm_hot_city.imageset/hm_hot_city@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/hm_hot_city_selected.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "hm_hot_city_selected@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "hm_hot_city_selected@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/hm_hot_city_selected.imageset/hm_hot_city_selected@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/hm_hot_city_selected.imageset/hm_hot_city_selected@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/hm_hot_city_selected.imageset/hm_hot_city_selected@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlOCDemo/FWSegmentedControl/Assets.xcassets/hm_hot_city_selected.imageset/hm_hot_city_selected@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/Base.lproj/LaunchScreen.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 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/FWNavigationController.h: -------------------------------------------------------------------------------- 1 | // 2 | // FWNavigationController.h 3 | // FWSegmentedControl 4 | // 5 | // Created by xfg on 2018/3/29. 6 | // Copyright © 2018年 xfg. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface FWNavigationController : UINavigationController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/FWNavigationController.m: -------------------------------------------------------------------------------- 1 | // 2 | // FWNavigationController.m 3 | // FWSegmentedControl 4 | // 5 | // Created by xfg on 2018/3/29. 6 | // Copyright © 2018年 xfg. All rights reserved. 7 | // 8 | 9 | #import "FWNavigationController.h" 10 | 11 | @interface FWNavigationController () 12 | 13 | @end 14 | 15 | @implementation FWNavigationController 16 | 17 | - (void)viewDidLoad 18 | { 19 | [super viewDidLoad]; 20 | 21 | [self.navigationBar setTranslucent:NO]; 22 | 23 | self.edgesForExtendedLayout = UIRectEdgeNone; 24 | self.extendedLayoutIncludesOpaqueBars = NO; 25 | } 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/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 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIRequiredDeviceCapabilities 26 | 27 | armv7 28 | 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeRight 33 | UIInterfaceOrientationLandscapeLeft 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // FWSegmentedControl 4 | // 5 | // Created by xfg on 2018/3/16. 6 | // Copyright © 2018年 xfg. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // FWSegmentedControl 4 | // 5 | // Created by xfg on 2018/3/16. 6 | // Copyright © 2018年 xfg. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "FWSegmentedControl-Swift.h" 11 | #import 12 | #import "ViewController2.h" 13 | 14 | @interface ViewController () 15 | 16 | @property (nonatomic, strong) UIScrollView *scrollView; // ScrollView 17 | @property (nonatomic, strong) NSArray *sectionTitles3; 18 | 19 | @property (nonatomic, assign) NSInteger startPage; // Segmented的滑块起始页 20 | @property (nonatomic, assign) BOOL isClickedSegmented; // 是否点击了Segmented的滑块 21 | 22 | @property (nonatomic, strong) FWSegmentedControl *segmentedControl7; 23 | 24 | @end 25 | 26 | @implementation ViewController 27 | 28 | - (void)viewDidLoad { 29 | [super viewDidLoad]; 30 | 31 | self.edgesForExtendedLayout = UIRectEdgeNone; 32 | self.view.backgroundColor = UIColor.lightGrayColor; 33 | self.navigationItem.title = @"FWSegmentedControl"; 34 | 35 | NSArray *images2 = @[[UIImage imageNamed:@"a"], [UIImage imageNamed:@"b"], [UIImage imageNamed:@"c"]]; 36 | 37 | NSArray *selectedImages2 = @[[UIImage imageNamed:@"a-selected"], [UIImage imageNamed:@"b-selected"], [UIImage imageNamed:@"c-selected"]]; 38 | 39 | self.sectionTitles3 = @[@"福建", @"直播", @"小视频"]; 40 | 41 | 42 | // 例一 43 | NSArray *sectionTitles = @[@"关注", @"游戏", @"附近", @"体育", @"女神范", @"运动啦啦", @"歌舞", @"吃鸡", @"户外", @"脱口秀"]; 44 | FWSegmentedControl *segmentedControl = [FWSegmentedControl segmentedWithScType:SCTypeText scWidthStyle:SCWidthStyleDynamicFixedSuper sectionTitleArray:nil sectionImageArray:nil sectionSelectedImageArray:nil frame:CGRectMake(0, 0, self.view.frame.size.width, 50)]; 45 | 46 | segmentedControl.sectionTitleArray = sectionTitles; 47 | segmentedControl.scSelectionIndicatorStyle = SCSelectionIndicatorStyleFullWidthStripe; 48 | 49 | [self.view addSubview:segmentedControl]; 50 | 51 | 52 | 53 | // 例二 54 | FWSegmentedControl *segmentedControl2 = [FWSegmentedControl segmentedWithScType:SCTypeText scWidthStyle:SCWidthStyleDynamicFixedSuper sectionTitleArray:sectionTitles sectionImageArray:nil sectionSelectedImageArray:nil frame:CGRectMake(0, CGRectGetMaxY(segmentedControl.frame) + 10, self.view.frame.size.width, 40)]; 55 | 56 | segmentedControl2.selectedSegmentIndex = 1; 57 | 58 | segmentedControl2.scSelectionIndicatorStyle = SCSelectionIndicatorStyleContentWidthStripe; 59 | segmentedControl2.scSelectionIndicatorLocation = SCSelectionIndicatorLocationDown; 60 | segmentedControl2.segmentEdgeInset = UIEdgeInsetsMake(0, 10, 0, 10); 61 | 62 | segmentedControl2.selectionIndicatorColor = UIColor.redColor; 63 | segmentedControl2.selectionIndicatorHeight = 3; 64 | 65 | segmentedControl2.titleTextAttributes = @{NSForegroundColorAttributeName: UIColor.grayColor, NSFontAttributeName: [UIFont systemFontOfSize:13.0]}; 66 | segmentedControl2.selectedTitleTextAttributes = @{NSForegroundColorAttributeName: UIColor.redColor, NSFontAttributeName: [UIFont systemFontOfSize:13.0]}; 67 | 68 | [self.view addSubview:segmentedControl2]; 69 | 70 | 71 | 72 | // 例三 73 | NSArray *sectionTitles2 = @[@"女神", @"运动啦啦", @"歌舞"]; 74 | 75 | FWSegmentedControl *segmentedControl3 = [FWSegmentedControl segmentedWithScType:SCTypeText scWidthStyle:SCWidthStyleDynamicFixedSuper sectionTitleArray:sectionTitles2 sectionImageArray:nil sectionSelectedImageArray:nil frame:CGRectMake(0, CGRectGetMaxY(segmentedControl2.frame) + 10, self.view.frame.size.width, 40)]; 76 | 77 | segmentedControl3.scSelectionIndicatorStyle = SCSelectionIndicatorStyleBox; 78 | segmentedControl3.scSelectionIndicatorLocation = SCSelectionIndicatorLocationDown; 79 | segmentedControl3.segmentEdgeInset = UIEdgeInsetsMake(0, 10, 0, 10); 80 | 81 | segmentedControl3.selectionIndicatorColor = UIColor.redColor; 82 | segmentedControl3.selectionIndicatorHeight = 3; 83 | 84 | segmentedControl3.selectionIndicatorBoxColor = UIColor.greenColor; 85 | segmentedControl3.selectionIndicatorBoxOpacity = 0.4; 86 | 87 | segmentedControl3.verticalDividerEnabled = YES; 88 | segmentedControl3.verticalDividerColor = UIColor.lightGrayColor; 89 | segmentedControl3.verticalDividerWidth = 1.0; 90 | 91 | segmentedControl3.titleTextAttributes = @{NSForegroundColorAttributeName: UIColor.grayColor, NSFontAttributeName: [UIFont systemFontOfSize:13.0]}; 92 | segmentedControl3.selectedTitleTextAttributes = @{NSForegroundColorAttributeName: UIColor.redColor, NSFontAttributeName: [UIFont systemFontOfSize:13.0]}; 93 | 94 | [self.view addSubview:segmentedControl3]; 95 | 96 | 97 | 98 | // 例四 99 | NSArray *images = @[[UIImage imageNamed:@"1"], [UIImage imageNamed:@"2"], [UIImage imageNamed:@"3"], [UIImage imageNamed:@"4"], [UIImage imageNamed:@"5"], [UIImage imageNamed:@"6"], [UIImage imageNamed:@"7"]]; 100 | 101 | NSArray *selectedImages = @[[UIImage imageNamed:@"1-selected"], [UIImage imageNamed:@"2-selected"], [UIImage imageNamed:@"3-selected"], [UIImage imageNamed:@"4-selected"], [UIImage imageNamed:@"5-selected"], [UIImage imageNamed:@"6-selected"], [UIImage imageNamed:@"7-selected"]]; 102 | 103 | FWSegmentedControl *segmentedControl4 = [FWSegmentedControl segmentedWithScType:SCTypeImages scWidthStyle:SCWidthStyleDynamicFixedSuper sectionTitleArray:nil sectionImageArray:images sectionSelectedImageArray:selectedImages frame:CGRectMake(0, CGRectGetMaxY(segmentedControl3.frame) + 10, self.view.frame.size.width, 40)]; 104 | 105 | segmentedControl4.scSelectionIndicatorStyle = SCSelectionIndicatorStyleContentWidthStripe; 106 | segmentedControl4.scSelectionIndicatorLocation = SCSelectionIndicatorLocationUp; 107 | segmentedControl4.segmentEdgeInset = UIEdgeInsetsMake(0, 10, 0, 10); 108 | 109 | segmentedControl4.selectionIndicatorColor = UIColor.redColor; 110 | segmentedControl4.selectionIndicatorHeight = 5; 111 | 112 | segmentedControl4.verticalDividerEnabled = YES; 113 | segmentedControl4.verticalDividerColor = UIColor.lightGrayColor; 114 | segmentedControl4.verticalDividerWidth = 1.0; 115 | 116 | [self.view addSubview:segmentedControl4]; 117 | 118 | 119 | // 例五 120 | NSDictionary *sectionSelectedImageDict = @{@(0) : [[FWSectionImageItem alloc] initWithItemImage:[UIImage imageNamed:@"hm_hot_city"] itemSelectedImage:[UIImage imageNamed:@"hm_hot_city_selected"]]}; 121 | 122 | FWSegmentedControl *segmentedControl5 = [FWSegmentedControl segmentedWithScType:SCTypeTextImages scWidthStyle:SCWidthStyleDynamic sectionTitleArray:self.sectionTitles3 sectionSelectedImageDict:sectionSelectedImageDict frame:CGRectMake(0, CGRectGetMaxY(segmentedControl4.frame) + 10, self.view.frame.size.width, 40)]; 123 | 124 | segmentedControl5.scSelectionIndicatorStyle = SCSelectionIndicatorStyleContentWidthStripe; 125 | segmentedControl5.scSelectionIndicatorLocation = SCSelectionIndicatorLocationDown; 126 | segmentedControl5.scImagePosition = SCImagePositionRightOfText; 127 | segmentedControl5.segmentEdgeInset = UIEdgeInsetsMake(0, 10, 0, 10); 128 | 129 | segmentedControl5.selectionIndicatorColor = UIColor.redColor; 130 | segmentedControl5.selectionIndicatorHeight = 3; 131 | segmentedControl5.selectionIndicatorEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 5); 132 | 133 | segmentedControl5.textImageSpacing = 4; 134 | 135 | segmentedControl5.titleTextAttributes = @{NSForegroundColorAttributeName: UIColor.grayColor, NSFontAttributeName: [UIFont systemFontOfSize:13.0]}; 136 | segmentedControl5.selectedTitleTextAttributes = @{NSForegroundColorAttributeName: UIColor.redColor, NSFontAttributeName: [UIFont systemFontOfSize:13.0]}; 137 | 138 | segmentedControl5.indexSecondClickedBlock = ^(NSInteger index) { 139 | NSLog(@"已经选中了某个index后再次点击的回调:%ld", (long)index); 140 | }; 141 | 142 | [self.view addSubview:segmentedControl5]; 143 | 144 | 145 | // 例六 146 | FWSegmentedControl *segmentedControl6 = [FWSegmentedControl segmentedWithScType:SCTypeTextImages scWidthStyle:SCWidthStyleFixed sectionTitleArray:self.sectionTitles3 sectionImageArray:images2 sectionSelectedImageArray:selectedImages2 frame:CGRectMake(0, CGRectGetMaxY(segmentedControl5.frame) + 10, self.view.frame.size.width, 50)]; 147 | 148 | segmentedControl6.scSelectionIndicatorStyle = SCSelectionIndicatorStyleArrowDown; 149 | segmentedControl6.scSelectionIndicatorLocation = SCSelectionIndicatorLocationDown; 150 | segmentedControl6.scImagePosition = SCImagePositionAboveText; 151 | segmentedControl6.segmentEdgeInset = UIEdgeInsetsMake(0, 10, 0, 10); 152 | 153 | segmentedControl6.selectionIndicatorColor = UIColor.redColor; 154 | segmentedControl6.selectionIndicatorHeight = 5; 155 | segmentedControl6.arrowWidth = 15.0; 156 | 157 | segmentedControl6.verticalDividerEnabled = YES; 158 | segmentedControl6.verticalDividerColor = UIColor.lightGrayColor; 159 | segmentedControl6.verticalDividerWidth = 1.0; 160 | 161 | segmentedControl6.textImageSpacing = 4; 162 | 163 | segmentedControl6.titleTextAttributes = @{NSForegroundColorAttributeName: UIColor.grayColor, NSFontAttributeName: [UIFont systemFontOfSize:13.0]}; 164 | segmentedControl6.selectedTitleTextAttributes = @{NSForegroundColorAttributeName: UIColor.redColor, NSFontAttributeName: [UIFont systemFontOfSize:13.0]}; 165 | 166 | [self.view addSubview:segmentedControl6]; 167 | 168 | 169 | // 例七 170 | self.segmentedControl7 = [FWSegmentedControl segmentedWithScType:SCTypeTextImages scWidthStyle:SCWidthStyleDynamicFixedSuper sectionTitleArray:self.sectionTitles3 sectionImageArray:images2 sectionSelectedImageArray:selectedImages2 frame:CGRectMake(0, CGRectGetMaxY(segmentedControl6.frame) + 10, self.view.frame.size.width, 40)]; 171 | 172 | self.segmentedControl7.scSelectionIndicatorStyle = SCSelectionIndicatorStyleFullWidthStripe; 173 | self.segmentedControl7.scSelectionIndicatorLocation = SCSelectionIndicatorLocationDown; 174 | self.segmentedControl7.scImagePosition = SCImagePositionRightOfText; 175 | self.segmentedControl7.segmentEdgeInset = UIEdgeInsetsMake(0, 10, 0, 10); 176 | 177 | self.segmentedControl7.selectionIndicatorColor = UIColor.redColor; 178 | self.segmentedControl7.selectionIndicatorHeight = 3; 179 | 180 | self.segmentedControl7.verticalDividerEnabled = YES; 181 | self.segmentedControl7.verticalDividerColor = UIColor.lightGrayColor; 182 | self.segmentedControl7.verticalDividerWidth = 1.0; 183 | 184 | self.segmentedControl7.textImageSpacing = 4; 185 | 186 | self.segmentedControl7.titleTextAttributes = @{NSForegroundColorAttributeName: UIColor.grayColor, NSFontAttributeName: [UIFont systemFontOfSize:13.0]}; 187 | self.segmentedControl7.selectedTitleTextAttributes = @{NSForegroundColorAttributeName: UIColor.redColor, NSFontAttributeName: [UIFont systemFontOfSize:13.0]}; 188 | 189 | __weak typeof(self) ws = self; 190 | self.segmentedControl7.indexChangeBlock = ^(NSInteger index) { 191 | 192 | ws.isClickedSegmented = YES; 193 | [ws.scrollView scrollRectToVisible:CGRectMake(ws.view.frame.size.width * index, 0, ws.view.frame.size.width, CGRectGetHeight(ws.scrollView.frame)) animated:YES]; 194 | }; 195 | 196 | [self.view addSubview:self.segmentedControl7]; 197 | 198 | 199 | self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.segmentedControl7.frame), self.view.frame.size.width, self.view.frame.size.height - CGRectGetMaxY(self.segmentedControl7.frame))]; 200 | self.scrollView.delegate = self; 201 | self.scrollView.backgroundColor = UIColor.clearColor; 202 | self.scrollView.pagingEnabled = YES; 203 | self.scrollView.showsHorizontalScrollIndicator = NO; 204 | self.scrollView.bounces = NO; 205 | self.scrollView.contentSize = CGSizeMake(self.view.frame.size.width * [self.sectionTitles3 count], CGRectGetHeight(self.scrollView.frame)); 206 | [self.scrollView scrollRectToVisible:CGRectMake(0, 0, self.view.frame.size.width, CGRectGetHeight(self.scrollView.frame)) animated:NO]; 207 | [self.view addSubview:self.scrollView]; 208 | 209 | [self.scrollView addSubview:[self setupUIView:0]]; 210 | [self.scrollView addSubview:[self setupUIView:1]]; 211 | [self.scrollView addSubview:[self setupUIView:2]]; 212 | 213 | self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"多级联动>" style:UIBarButtonItemStylePlain target:self action:@selector(goNextVC)]; 214 | } 215 | 216 | - (UILabel *)setupUIView:(int)index 217 | { 218 | UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(self.view.frame.size.width * index, 0, self.view.frame.size.width, CGRectGetHeight(self.scrollView.frame))]; 219 | label.text = self.sectionTitles3[index]; 220 | label.textColor = UIColor.whiteColor; 221 | label.textAlignment = NSTextAlignmentCenter; 222 | label.backgroundColor = [UIColor colorWithRed:(float)(1+arc4random()%99)/100 green:(float)(1+arc4random()%99)/100 blue:(float)(1+arc4random()%99)/100 alpha:1]; 223 | return label; 224 | } 225 | 226 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView 227 | { 228 | if (!self.isClickedSegmented) 229 | { 230 | CGFloat pageWidth = scrollView.frame.size.width; 231 | NSInteger tmpPage = scrollView.contentOffset.x / pageWidth; 232 | float tmpPage2 = scrollView.contentOffset.x / pageWidth; 233 | NSInteger page = tmpPage2-tmpPage>=0.5 ? tmpPage+1 : tmpPage; 234 | 235 | if (_startPage != page) 236 | { 237 | [self.segmentedControl7 setSelectedSegmentIndexWithIndex:page animated:YES]; 238 | _startPage = page; 239 | } 240 | } 241 | } 242 | 243 | - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView 244 | { 245 | CGFloat pageWidth = scrollView.frame.size.width; 246 | NSInteger page = scrollView.contentOffset.x / pageWidth; 247 | 248 | self.isClickedSegmented = NO; 249 | 250 | [self.segmentedControl7 setSelectedSegmentIndexWithIndex:page animated:YES]; 251 | } 252 | 253 | - (void)goNextVC 254 | { 255 | [self.navigationController pushViewController:[[ViewController2 alloc] init] animated:YES]; 256 | } 257 | 258 | - (void)didReceiveMemoryWarning { 259 | [super didReceiveMemoryWarning]; 260 | // Dispose of any resources that can be recreated. 261 | } 262 | 263 | 264 | @end 265 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/ViewController2.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController2.h 3 | // FWSegmentedControl 4 | // 5 | // Created by 叶子 on 2018/3/20. 6 | // Copyright © 2018年 xfg. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController2 : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/ViewController2.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController2.m 3 | // FWSegmentedControl 4 | // 5 | // Created by 叶子 on 2018/3/20. 6 | // Copyright © 2018年 xfg. All rights reserved. 7 | // 8 | 9 | #import "ViewController2.h" 10 | #import 11 | 12 | #define segmentedControlHeight 40 13 | #define segmentedControl2Height 40 14 | 15 | @interface ViewController2 () 16 | 17 | @property (nonatomic, strong) FWSegmentedControl *segmentedControl; 18 | @property (nonatomic, strong) UIScrollView *scrollView; // ScrollView 19 | 20 | @property (nonatomic, strong) NSArray *sectionTitles; 21 | @property (nonatomic, strong) NSArray *sectionTitles2; 22 | @property (nonatomic, strong) NSArray *sectionTitles3; 23 | 24 | @property (nonatomic, strong) NSMutableArray *segmentedControlArray; 25 | 26 | @end 27 | 28 | @implementation ViewController2 29 | 30 | - (void)viewDidLoad { 31 | [super viewDidLoad]; 32 | 33 | self.edgesForExtendedLayout = UIRectEdgeNone; 34 | self.view.backgroundColor = UIColor.lightGrayColor; 35 | 36 | self.sectionTitles = @[@"yezi", @"开发语言"]; 37 | self.sectionTitles2 = @[@"叶子", @"椰子啦", @"叶紫", @"叶梓"]; 38 | self.sectionTitles3 = @[@"Swift", @"OC", @"Android", @"RN"]; 39 | 40 | self.segmentedControlArray = [NSMutableArray array]; 41 | 42 | 43 | self.segmentedControl = [FWSegmentedControl segmentedWithScType:SCTypeText scWidthStyle:SCWidthStyleDynamicFixedSuper sectionTitleArray:self.sectionTitles sectionImageArray:nil sectionSelectedImageArray:nil frame:CGRectMake(0, 0, self.view.frame.size.width, segmentedControlHeight)]; 44 | 45 | self.segmentedControl.scSelectionIndicatorStyle = SCSelectionIndicatorStyleFullWidthStripe; 46 | self.segmentedControl.scSelectionIndicatorLocation = SCSelectionIndicatorLocationDown; 47 | self.segmentedControl.segmentEdgeInset = UIEdgeInsetsMake(0, 10, 0, 10); 48 | 49 | self.segmentedControl.selectionIndicatorColor = UIColor.redColor; 50 | self.segmentedControl.selectionIndicatorHeight = 3; 51 | 52 | self.segmentedControl.verticalDividerEnabled = YES; 53 | self.segmentedControl.verticalDividerColor = UIColor.lightGrayColor; 54 | self.segmentedControl.verticalDividerWidth = 1.0; 55 | 56 | self.segmentedControl.titleTextAttributes = @{NSForegroundColorAttributeName: UIColor.grayColor, NSFontAttributeName: [UIFont systemFontOfSize:13.0]}; 57 | self.segmentedControl.selectedTitleTextAttributes = @{NSForegroundColorAttributeName: UIColor.redColor, NSFontAttributeName: [UIFont systemFontOfSize:13.0]}; 58 | 59 | __weak typeof(self) ws = self; 60 | self.segmentedControl.indexChangeBlock = ^(NSInteger index) { 61 | 62 | [ws.scrollView scrollRectToVisible:CGRectMake(ws.view.frame.size.width * index, 0, ws.view.frame.size.width, CGRectGetHeight(ws.scrollView.frame)) animated:YES]; 63 | }; 64 | 65 | [self.view addSubview:self.segmentedControl]; 66 | 67 | UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.segmentedControl.frame), self.view.frame.size.width, 1)]; 68 | lineView.backgroundColor = UIColor.lightGrayColor; 69 | [self.view addSubview:lineView]; 70 | 71 | 72 | self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.segmentedControl.frame)+1, self.view.frame.size.width, self.view.frame.size.height - CGRectGetMaxY(self.segmentedControl.frame))]; 73 | self.scrollView.tag = 0; 74 | self.scrollView.delegate = self; 75 | self.scrollView.backgroundColor = UIColor.clearColor; 76 | self.scrollView.pagingEnabled = YES; 77 | self.scrollView.showsHorizontalScrollIndicator = NO; 78 | self.scrollView.bounces = NO; 79 | self.scrollView.contentSize = CGSizeMake(self.view.frame.size.width * [self.sectionTitles count], CGRectGetHeight(self.scrollView.frame)); 80 | [self.scrollView scrollRectToVisible:CGRectMake(0, 0, self.view.frame.size.width, CGRectGetHeight(self.scrollView.frame)) animated:NO]; 81 | [self.view addSubview:self.scrollView]; 82 | 83 | FWSegmentedControl *segmentedControl2 = [self setupSegmentedControl:0 sectionTitleArray:self.sectionTitles2]; 84 | FWSegmentedControl *segmentedControl3 = [self setupSegmentedControl:1 sectionTitleArray:self.sectionTitles3]; 85 | 86 | [self.segmentedControlArray addObject:segmentedControl2]; 87 | [self.segmentedControlArray addObject:segmentedControl3]; 88 | 89 | [self.scrollView addSubview:segmentedControl2]; 90 | [self.scrollView addSubview:segmentedControl3]; 91 | 92 | } 93 | 94 | - (FWSegmentedControl *)setupSegmentedControl:(int)index sectionTitleArray:(NSArray *)sectionTitleArray 95 | { 96 | FWSegmentedControl *segmentedControl2 = [FWSegmentedControl segmentedWithScType:SCTypeText scWidthStyle:SCWidthStyleDynamicFixedSuper sectionTitleArray:sectionTitleArray sectionImageArray:nil sectionSelectedImageArray:nil frame:CGRectMake(self.view.frame.size.width * index, 0, self.view.frame.size.width, segmentedControl2Height)]; 97 | 98 | segmentedControl2.scSelectionIndicatorStyle = SCSelectionIndicatorStyleFullWidthStripe; 99 | segmentedControl2.scSelectionIndicatorLocation = SCSelectionIndicatorLocationDown; 100 | segmentedControl2.segmentEdgeInset = UIEdgeInsetsMake(0, 10, 0, 10); 101 | 102 | segmentedControl2.selectionIndicatorColor = UIColor.redColor; 103 | segmentedControl2.selectionIndicatorHeight = 3; 104 | 105 | segmentedControl2.verticalDividerEnabled = YES; 106 | segmentedControl2.verticalDividerColor = UIColor.lightGrayColor; 107 | segmentedControl2.verticalDividerWidth = 1.0; 108 | 109 | segmentedControl2.titleTextAttributes = @{NSForegroundColorAttributeName: UIColor.grayColor, NSFontAttributeName: [UIFont systemFontOfSize:13.0]}; 110 | segmentedControl2.selectedTitleTextAttributes = @{NSForegroundColorAttributeName: UIColor.redColor, NSFontAttributeName: [UIFont systemFontOfSize:13.0]}; 111 | 112 | UIScrollView *scrollView2 = [self setupScrollView:index sectionTitleArray:sectionTitleArray]; 113 | [self.scrollView addSubview:scrollView2]; 114 | 115 | __weak typeof(self) ws = self; 116 | segmentedControl2.indexChangeBlock = ^(NSInteger index) { 117 | 118 | [scrollView2 scrollRectToVisible:CGRectMake(ws.view.frame.size.width * index, 0, ws.view.frame.size.width, CGRectGetHeight(scrollView2.frame)) animated:YES]; 119 | }; 120 | 121 | return segmentedControl2; 122 | } 123 | 124 | - (UIScrollView *)setupScrollView:(int)index sectionTitleArray:(NSArray *)sectionTitleArray 125 | { 126 | UIScrollView *scrollView2 = [[UIScrollView alloc] initWithFrame:CGRectMake(self.view.frame.size.width * index, segmentedControl2Height, self.view.frame.size.width, self.view.frame.size.height - CGRectGetMaxY(self.segmentedControl.frame) - segmentedControl2Height)]; 127 | 128 | scrollView2.tag = 1 + index; 129 | 130 | scrollView2.delegate = self; 131 | scrollView2.backgroundColor = UIColor.clearColor; 132 | scrollView2.pagingEnabled = YES; 133 | scrollView2.showsHorizontalScrollIndicator = NO; 134 | scrollView2.bounces = NO; 135 | scrollView2.contentSize = CGSizeMake(self.view.frame.size.width * [sectionTitleArray count], CGRectGetHeight(scrollView2.frame)); 136 | [scrollView2 scrollRectToVisible:CGRectMake(0, 0, self.view.frame.size.width, CGRectGetHeight(scrollView2.frame)) animated:NO]; 137 | [self.view addSubview:scrollView2]; 138 | 139 | for (int i = 0; i < sectionTitleArray.count; i++) { 140 | [scrollView2 addSubview:[self setupLabel:i title:sectionTitleArray[i]]]; 141 | } 142 | 143 | return scrollView2; 144 | } 145 | 146 | - (UILabel *)setupLabel:(int)index title:(NSString *)title 147 | { 148 | UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(self.view.frame.size.width * index, 0, self.view.frame.size.width, CGRectGetHeight(self.scrollView.frame))]; 149 | label.text = self.sectionTitles3[index]; 150 | label.textColor = UIColor.whiteColor; 151 | label.textAlignment = NSTextAlignmentCenter; 152 | label.backgroundColor = [UIColor colorWithRed:(float)(1+arc4random()%99)/100 green:(float)(1+arc4random()%99)/100 blue:(float)(1+arc4random()%99)/100 alpha:1]; 153 | return label; 154 | } 155 | 156 | //- (void)scrollViewDidScroll:(UIScrollView *)scrollView 157 | //{ 158 | // CGFloat pageWidth = scrollView.frame.size.width; 159 | // NSInteger tmpPage = scrollView.contentOffset.x / pageWidth; 160 | // float tmpPage2 = scrollView.contentOffset.x / pageWidth; 161 | // NSInteger page = tmpPage2-tmpPage>=0.5 ? tmpPage+1 : tmpPage; 162 | // if (scrollView.tag == 0) { 163 | // [self.segmentedControl setSelectedSegmentIndexWithIndex:page animated:YES]; 164 | // } else { 165 | // FWSegmentedControl *segmentedControll = self.segmentedControlArray[scrollView.tag-1]; 166 | // [segmentedControll setSelectedSegmentIndexWithIndex:page animated:YES]; 167 | // } 168 | //} 169 | 170 | - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView 171 | { 172 | CGFloat pageWidth = scrollView.frame.size.width; 173 | NSInteger page = scrollView.contentOffset.x / pageWidth; 174 | 175 | if (scrollView.tag == 0) { 176 | [self.segmentedControl setSelectedSegmentIndexWithIndex:page animated:YES]; 177 | } else { 178 | FWSegmentedControl *segmentedControll = self.segmentedControlArray[scrollView.tag-1]; 179 | [segmentedControll setSelectedSegmentIndexWithIndex:page animated:YES]; 180 | } 181 | } 182 | 183 | - (void)didReceiveMemoryWarning { 184 | [super didReceiveMemoryWarning]; 185 | // Dispose of any resources that can be recreated. 186 | } 187 | 188 | @end 189 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControl/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // FWSegmentedControl 4 | // 5 | // Created by xfg on 2018/3/16. 6 | // Copyright © 2018年 xfg. 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 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControlTests/FWSegmentedControlTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // FWSegmentedControlTests.m 3 | // FWSegmentedControlTests 4 | // 5 | // Created by xfg on 2018/3/16. 6 | // Copyright © 2018年 xfg. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface FWSegmentedControlTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation FWSegmentedControlTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControlTests/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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControlUITests/FWSegmentedControlUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // FWSegmentedControlUITests.m 3 | // FWSegmentedControlUITests 4 | // 5 | // Created by xfg on 2018/3/16. 6 | // Copyright © 2018年 xfg. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface FWSegmentedControlUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation FWSegmentedControlUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/FWSegmentedControlUITests/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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/Podfile: -------------------------------------------------------------------------------- 1 | target 'FWSegmentedControl' do 2 | use_frameworks! 3 | 4 | pod 'FWSegmentedControl' 5 | 6 | end 7 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - FWSegmentedControl (2.2.0) 3 | 4 | DEPENDENCIES: 5 | - FWSegmentedControl 6 | 7 | SPEC REPOS: 8 | trunk: 9 | - FWSegmentedControl 10 | 11 | SPEC CHECKSUMS: 12 | FWSegmentedControl: fd6d3b9620cab1cdecedef05d000982247d66865 13 | 14 | PODFILE CHECKSUM: c69c6a5b0c3433f2de84029319950f6b327076e0 15 | 16 | COCOAPODS: 1.8.4 17 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/Pods/FWSegmentedControl/README.md: -------------------------------------------------------------------------------- 1 | # ![](https://github.com/choiceyou/FWSegmentedControl/blob/master/%E6%95%88%E6%9E%9C/FWSegmentedControl.png) 2 | 3 | [![Platform](http://img.shields.io/badge/platform-iOS-blue.svg?style=flat)](http://cocoapods.org/?q=FWSegmentedControl)  4 | ![Language](https://img.shields.io/badge/language-swift-orange.svg?style=flat)  5 | [![License](http://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/choiceyou/FWSegmentedControl/blob/master/FWSegmentedControl/LICENSE) 6 | 7 | 8 | 9 | ## 支持pod导入: 10 | 11 | ```cocoaPods 12 | use_frameworks! 13 | pod 'FWSegmentedControl' 14 | 注意: 15 | 1、如出现 [!] Unable to find a specification for 'FWSegmentedControl' 错误 或 看不到最新的版本, 16 | 可执行 pod repo update 命令更新一下本地pod仓库。 17 | 2、use_frameworks! 的使用: 18 | (1)纯OC项目中,通过cocoapods导入OC库时,一般都不使用use_frameworks! 19 | (2)纯swift项目中,通过cocoapods导入swift库时,必须使用use_frameworks! 20 | (3)只要是通过cocoapods导入swift库时,都必须使用use_frameworks! 21 | (4)使用动态链接库dynamic frameworks时,必须使用use_frameworks! 22 | ``` 23 | 24 | 25 | ## 可设置参数: 26 | ```参数 27 | /// 标题 28 | @objc public var sectionTitleArray: [String]? 29 | /// 图片 30 | @objc public var sectionImageArray: [UIImage]? 31 | /// 选中图片 32 | @objc public var sectionSelectedImageArray: [UIImage]? 33 | 34 | /// segment类型 35 | @objc public var scType = SCType.text 36 | /// segment宽度 37 | @objc public var scWidthStyle = SCWidthStyle.fixed 38 | /// 图片相对于文字的位置 39 | @objc public var scImagePosition: SCImagePosition = .leftOfText 40 | /// 选中标识符类型 41 | @objc public var scSelectionIndicatorStyle = SCSelectionIndicatorStyle.contentWidthStripe 42 | /// 选中标识符位置 43 | @objc public var scSelectionIndicatorLocation = SCSelectionIndicatorLocation.down 44 | /// 边框类型 45 | public var scBorderType: SCBorderType = .none 46 | 47 | /// 选中标识符高度,注意:self.scSelectionIndicatorStyle == .box || self.scSelectionIndicatorStyle == .none 时无效 48 | @objc public var selectionIndicatorHeight: CGFloat = 3.0 49 | /// 选中标识符,当 SCSelectionIndicatorLocation == up 时,底部edge无效;反之,顶部edge无效; 50 | @objc public var selectionIndicatorEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0) 51 | /// 选中标识符颜色 52 | @objc public var selectionIndicatorColor = UIColor.red 53 | @objc public var selectionIndicatorBoxColor = UIColor.gray 54 | 55 | /// 滑动或者选中回调 56 | @objc public var indexChangeBlock: SCIndexChangeBlock? 57 | /// 标题NSAttributedString回调 58 | @objc public var titleFormatterBlock: SCTitleFormatterBlock? 59 | /// segment的Inset属性 60 | @objc public var segmentEdgeInset = UIEdgeInsetsMake(0, 5, 0, 5) 61 | @objc public var enlargeEdgeInset = UIEdgeInsetsMake(0, 0, 0, 0) 62 | 63 | /// 未选中的标题属性 64 | @objc public var titleTextAttributes: [NSAttributedStringKey: Any]? 65 | /// 选中的标题属性 66 | @objc public var selectedTitleTextAttributes: [NSAttributedStringKey: Any]? 67 | 68 | /// 是否可以拖动 69 | @objc public var userDraggable = true 70 | /// 是否可以点击 71 | @objc public var touchEnabled = true 72 | 73 | /// segment的边框颜色 74 | @objc public var segmentBorderColor = UIColor.black 75 | /// segment的边框大小 76 | @objc public var segmentBorderWidth: CGFloat = 1.0 77 | 78 | /// 选中或者滑动时是否需要动画 79 | @objc public var shouldAnimateUserSelection = true 80 | 81 | /// 选中标识符为箭头的宽度 82 | @objc public var arrowWidth: CGFloat = 6.0 83 | 84 | /// 选中表示符为box时的opacity值 85 | @objc public var selectionIndicatorBoxOpacity: CGFloat = 0.2 86 | 87 | /// segment之间的间隔竖线的宽度 88 | @objc public var verticalDividerWidth: CGFloat = 1.0 89 | /// 是否需要segment之间的间隔竖线 90 | @objc public var verticalDividerEnabled = false 91 | /// segment之间的间隔竖线的颜色 92 | @objc public var verticalDividerColor = UIColor.black 93 | 94 | /// 选中标识符滑动的时间 95 | @objc public var indicatorAnimatedTimes: CFTimeInterval = 0.15 96 | 97 | /// self.scType == .textImages 时,文字、图片的间隔 98 | @objc public var textImageSpacing: CGFloat = 4.0 99 | 100 | /// 选中项的下标 101 | @objc public var selectedSegmentIndex: Int = 0 102 | ``` 103 | 104 | 105 | 106 | ## 简单使用:(注:可下载demo具体查看,分别有OC、Swift的demo) 107 | 108 | ```swift 109 | /// 类初始化方法 110 | /// 111 | /// - Parameters: 112 | /// - scType: segment类型 113 | /// - sectionTitleArray: 标题,可传nil,后续再设置 114 | /// - sectionImageArray: 图片,可传nil,后续再设置 115 | /// - sectionSelectedImageArray: 选中图片,可传nil,后续再设置 116 | /// - frame: frame 117 | @objc open class func segmentedWith(scType: SCType, 118 | scWidthStyle: SCWidthStyle, 119 | sectionTitleArray: [String]?, 120 | sectionImageArray: [UIImage]?, 121 | sectionSelectedImageArray: [UIImage]?, 122 | frame: CGRect) -> FWSegmentedControl 123 | ``` 124 | 125 | ### OC: 126 | ```oc 127 | [FWSegmentedControl segmentedWithScType: SCTypeText 128 | scWidthStyle: SCWidthStyleDynamicFixedSuper 129 | sectionTitleArray: @[@"关注", @"游戏", @"附近"] 130 | sectionImageArray: nil 131 | sectionSelectedImageArray: nil 132 | frame: CGRectMake(0, 40, self.view.frame.size.width, 50)]; 133 | ``` 134 | 135 | 136 | ### Swift:
137 | ```swift 138 | FWSegmentedControl.segmentedWith(scType: SCType.text, 139 | scWidthStyle: SCWidthStyle.fixed, 140 | sectionTitleArray: ["关注", "游戏", "附近"], 141 | sectionImageArray: nil, 142 | sectionSelectedImageArray: nil, 143 | frame: CGRect(x: 0, y: 40, width: Int(UIScreen.main.bounds.width), height: 50)) 144 | 145 | ``` 146 | 147 | 148 | 149 | ## 效果: 150 | 151 | ![](https://github.com/choiceyou/FWSegmentedControl/blob/master/%E6%95%88%E6%9E%9C/%E7%A4%BA%E4%BE%8B1.gif) 152 | ![](https://github.com/choiceyou/FWSegmentedControl/blob/master/%E6%95%88%E6%9E%9C/%E7%A4%BA%E4%BE%8B2.gif) 153 | 154 | 155 | 156 | ## 注意点: 157 | 158 | 一、本UI库是用Swift4.0编写的,所以安装或者拖入文件后需要把对应的Swift设置为4.0版本:
159 | (1)pod安装方式:![](https://github.com/choiceyou/FWSegmentedControl/blob/master/%E6%95%88%E6%9E%9C/%E8%AE%BE%E7%BD%AE1.jpg) 160 | (2)文件拖入方式:Targets --> Build Setting 做相同的设置 161 | 162 | 二、如果是文件拖入方式,需要设置OC、Swift混编等,相关问题网上有很多解答,我这边就不再重复了 163 | 164 | 165 | 166 | ## 更新记录: 167 | 168 | • v2.1.7: 169 | - [x] 添加:sectionSelectedImageDict,使得在一个FWSegmentedControl中支持图片+文字、图片、文字的混排形式; 170 | - [x] 选中标识符可设置圆角,默认圆角值为:1.5f; 171 | - [x] 新增已经选中了某个index后再次点击的回调:SCIndexSecondClickedBlock; 172 | - [x] 修复segmentEdgeInset位置右移的问题; 173 | - [x] 更多细节调整; 174 | 175 | 176 | 177 | ## 结尾语: 178 | 179 | - 使用过程中发现bug请issues或加入FW问题反馈群:670698309(此群只接受FW相关组件问题); 180 | - 有新的需求欢迎提出; 181 | 182 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - FWSegmentedControl (2.2.0) 3 | 4 | DEPENDENCIES: 5 | - FWSegmentedControl 6 | 7 | SPEC REPOS: 8 | trunk: 9 | - FWSegmentedControl 10 | 11 | SPEC CHECKSUMS: 12 | FWSegmentedControl: fd6d3b9620cab1cdecedef05d000982247d66865 13 | 14 | PODFILE CHECKSUM: c69c6a5b0c3433f2de84029319950f6b327076e0 15 | 16 | COCOAPODS: 1.8.4 17 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/Pods/Pods.xcodeproj/xcuserdata/xfg.xcuserdatad/xcschemes/FWSegmentedControl.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 50 | 51 | 53 | 54 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/Pods/Pods.xcodeproj/xcuserdata/xfg.xcuserdatad/xcschemes/Pods-FWSegmentedControl.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 | 68 | 69 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/Pods/Pods.xcodeproj/xcuserdata/xfg.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | FWSegmentedControl.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | Pods-FWSegmentedControl.xcscheme 13 | 14 | orderHint 15 | 1 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/Pods/Pods.xcodeproj/xcuserdata/yechen.xcuserdatad/xcschemes/FWSegmentedControl.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/Pods/Pods.xcodeproj/xcuserdata/yechen.xcuserdatad/xcschemes/Pods-FWSegmentedControl.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 50 | 51 | 53 | 54 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/Pods/Target Support Files/FWSegmentedControl/FWSegmentedControl-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 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 | 2.2.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/Pods/Target Support Files/FWSegmentedControl/FWSegmentedControl-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_FWSegmentedControl : NSObject 3 | @end 4 | @implementation PodsDummy_FWSegmentedControl 5 | @end 6 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/Pods/Target Support Files/FWSegmentedControl/FWSegmentedControl-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/Pods/Target Support Files/FWSegmentedControl/FWSegmentedControl-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double FWSegmentedControlVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char FWSegmentedControlVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/Pods/Target Support Files/FWSegmentedControl/FWSegmentedControl.modulemap: -------------------------------------------------------------------------------- 1 | framework module FWSegmentedControl { 2 | umbrella header "FWSegmentedControl-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/Pods/Target Support Files/FWSegmentedControl/FWSegmentedControl.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/FWSegmentedControl 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS 4 | PODS_BUILD_DIR = ${BUILD_DIR} 5 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 6 | PODS_ROOT = ${SRCROOT} 7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/FWSegmentedControl 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 11 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/Pods/Target Support Files/Pods-FWSegmentedControl/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 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.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/Pods/Target Support Files/Pods-FWSegmentedControl/Pods-FWSegmentedControl-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 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.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/Pods/Target Support Files/Pods-FWSegmentedControl/Pods-FWSegmentedControl-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | Generated by CocoaPods - https://cocoapods.org 4 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/Pods/Target Support Files/Pods-FWSegmentedControl/Pods-FWSegmentedControl-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Generated by CocoaPods - https://cocoapods.org 18 | Title 19 | 20 | Type 21 | PSGroupSpecifier 22 | 23 | 24 | StringsTable 25 | Acknowledgements 26 | Title 27 | Acknowledgements 28 | 29 | 30 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/Pods/Target Support Files/Pods-FWSegmentedControl/Pods-FWSegmentedControl-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_FWSegmentedControl : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_FWSegmentedControl 5 | @end 6 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/Pods/Target Support Files/Pods-FWSegmentedControl/Pods-FWSegmentedControl-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | set -u 4 | set -o pipefail 5 | 6 | function on_error { 7 | echo "$(realpath -mq "${0}"):$1: error: Unexpected failure" 8 | } 9 | trap 'on_error $LINENO' ERR 10 | 11 | if [ -z ${FRAMEWORKS_FOLDER_PATH+x} ]; then 12 | # If FRAMEWORKS_FOLDER_PATH is not set, then there's nowhere for us to copy 13 | # frameworks to, so exit 0 (signalling the script phase was successful). 14 | exit 0 15 | fi 16 | 17 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 18 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 19 | 20 | COCOAPODS_PARALLEL_CODE_SIGN="${COCOAPODS_PARALLEL_CODE_SIGN:-false}" 21 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 22 | 23 | # Used as a return value for each invocation of `strip_invalid_archs` function. 24 | STRIP_BINARY_RETVAL=0 25 | 26 | # This protects against multiple targets copying the same framework dependency at the same time. The solution 27 | # was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html 28 | RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????") 29 | 30 | # Copies and strips a vendored framework 31 | install_framework() 32 | { 33 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 34 | local source="${BUILT_PRODUCTS_DIR}/$1" 35 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 36 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 37 | elif [ -r "$1" ]; then 38 | local source="$1" 39 | fi 40 | 41 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 42 | 43 | if [ -L "${source}" ]; then 44 | echo "Symlinked..." 45 | source="$(readlink "${source}")" 46 | fi 47 | 48 | # Use filter instead of exclude so missing patterns don't throw errors. 49 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 50 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 51 | 52 | local basename 53 | basename="$(basename -s .framework "$1")" 54 | binary="${destination}/${basename}.framework/${basename}" 55 | 56 | if ! [ -r "$binary" ]; then 57 | binary="${destination}/${basename}" 58 | elif [ -L "${binary}" ]; then 59 | echo "Destination binary is symlinked..." 60 | dirname="$(dirname "${binary}")" 61 | binary="${dirname}/$(readlink "${binary}")" 62 | fi 63 | 64 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 65 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 66 | strip_invalid_archs "$binary" 67 | fi 68 | 69 | # Resign the code if required by the build settings to avoid unstable apps 70 | code_sign_if_enabled "${destination}/$(basename "$1")" 71 | 72 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 73 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 74 | local swift_runtime_libs 75 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u) 76 | for lib in $swift_runtime_libs; do 77 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 78 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 79 | code_sign_if_enabled "${destination}/${lib}" 80 | done 81 | fi 82 | } 83 | 84 | # Copies and strips a vendored dSYM 85 | install_dsym() { 86 | local source="$1" 87 | if [ -r "$source" ]; then 88 | # Copy the dSYM into a the targets temp dir. 89 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${DERIVED_FILES_DIR}\"" 90 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${DERIVED_FILES_DIR}" 91 | 92 | local basename 93 | basename="$(basename -s .framework.dSYM "$source")" 94 | binary="${DERIVED_FILES_DIR}/${basename}.framework.dSYM/Contents/Resources/DWARF/${basename}" 95 | 96 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 97 | if [[ "$(file "$binary")" == *"Mach-O "*"dSYM companion"* ]]; then 98 | strip_invalid_archs "$binary" 99 | fi 100 | 101 | if [[ $STRIP_BINARY_RETVAL == 1 ]]; then 102 | # Move the stripped file into its final destination. 103 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${DERIVED_FILES_DIR}/${basename}.framework.dSYM\" \"${DWARF_DSYM_FOLDER_PATH}\"" 104 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${DERIVED_FILES_DIR}/${basename}.framework.dSYM" "${DWARF_DSYM_FOLDER_PATH}" 105 | else 106 | # The dSYM was not stripped at all, in this case touch a fake folder so the input/output paths from Xcode do not reexecute this script because the file is missing. 107 | touch "${DWARF_DSYM_FOLDER_PATH}/${basename}.framework.dSYM" 108 | fi 109 | fi 110 | } 111 | 112 | # Copies the bcsymbolmap files of a vendored framework 113 | install_bcsymbolmap() { 114 | local bcsymbolmap_path="$1" 115 | local destination="${BUILT_PRODUCTS_DIR}" 116 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${bcsymbolmap_path}" "${destination}"" 117 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${bcsymbolmap_path}" "${destination}" 118 | } 119 | 120 | # Signs a framework with the provided identity 121 | code_sign_if_enabled() { 122 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY:-}" -a "${CODE_SIGNING_REQUIRED:-}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 123 | # Use the current code_sign_identity 124 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 125 | local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS:-} --preserve-metadata=identifier,entitlements '$1'" 126 | 127 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 128 | code_sign_cmd="$code_sign_cmd &" 129 | fi 130 | echo "$code_sign_cmd" 131 | eval "$code_sign_cmd" 132 | fi 133 | } 134 | 135 | # Strip invalid architectures 136 | strip_invalid_archs() { 137 | binary="$1" 138 | # Get architectures for current target binary 139 | binary_archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | awk '{$1=$1;print}' | rev)" 140 | # Intersect them with the architectures we are building for 141 | intersected_archs="$(echo ${ARCHS[@]} ${binary_archs[@]} | tr ' ' '\n' | sort | uniq -d)" 142 | # If there are no archs supported by this binary then warn the user 143 | if [[ -z "$intersected_archs" ]]; then 144 | echo "warning: [CP] Vendored binary '$binary' contains architectures ($binary_archs) none of which match the current build architectures ($ARCHS)." 145 | STRIP_BINARY_RETVAL=0 146 | return 147 | fi 148 | stripped="" 149 | for arch in $binary_archs; do 150 | if ! [[ "${ARCHS}" == *"$arch"* ]]; then 151 | # Strip non-valid architectures in-place 152 | lipo -remove "$arch" -output "$binary" "$binary" 153 | stripped="$stripped $arch" 154 | fi 155 | done 156 | if [[ "$stripped" ]]; then 157 | echo "Stripped $binary of architectures:$stripped" 158 | fi 159 | STRIP_BINARY_RETVAL=1 160 | } 161 | 162 | 163 | if [[ "$CONFIGURATION" == "Debug" ]]; then 164 | install_framework "${BUILT_PRODUCTS_DIR}/FWSegmentedControl/FWSegmentedControl.framework" 165 | fi 166 | if [[ "$CONFIGURATION" == "Release" ]]; then 167 | install_framework "${BUILT_PRODUCTS_DIR}/FWSegmentedControl/FWSegmentedControl.framework" 168 | fi 169 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 170 | wait 171 | fi 172 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/Pods/Target Support Files/Pods-FWSegmentedControl/Pods-FWSegmentedControl-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | XCASSET_FILES=() 10 | 11 | # This protects against multiple targets copying the same framework dependency at the same time. The solution 12 | # was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html 13 | RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????") 14 | 15 | case "${TARGETED_DEVICE_FAMILY}" in 16 | 1,2) 17 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 18 | ;; 19 | 1) 20 | TARGET_DEVICE_ARGS="--target-device iphone" 21 | ;; 22 | 2) 23 | TARGET_DEVICE_ARGS="--target-device ipad" 24 | ;; 25 | 3) 26 | TARGET_DEVICE_ARGS="--target-device tv" 27 | ;; 28 | 4) 29 | TARGET_DEVICE_ARGS="--target-device watch" 30 | ;; 31 | *) 32 | TARGET_DEVICE_ARGS="--target-device mac" 33 | ;; 34 | esac 35 | 36 | install_resource() 37 | { 38 | if [[ "$1" = /* ]] ; then 39 | RESOURCE_PATH="$1" 40 | else 41 | RESOURCE_PATH="${PODS_ROOT}/$1" 42 | fi 43 | if [[ ! -e "$RESOURCE_PATH" ]] ; then 44 | cat << EOM 45 | error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script. 46 | EOM 47 | exit 1 48 | fi 49 | case $RESOURCE_PATH in 50 | *.storyboard) 51 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" || true 52 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 53 | ;; 54 | *.xib) 55 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" || true 56 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 57 | ;; 58 | *.framework) 59 | echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" || true 60 | mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 61 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" || true 62 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 63 | ;; 64 | *.xcdatamodel) 65 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" || true 66 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom" 67 | ;; 68 | *.xcdatamodeld) 69 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" || true 70 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd" 71 | ;; 72 | *.xcmappingmodel) 73 | echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" || true 74 | xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm" 75 | ;; 76 | *.xcassets) 77 | ABSOLUTE_XCASSET_FILE="$RESOURCE_PATH" 78 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") 79 | ;; 80 | *) 81 | echo "$RESOURCE_PATH" || true 82 | echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY" 83 | ;; 84 | esac 85 | } 86 | 87 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 88 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 89 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then 90 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 91 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 92 | fi 93 | rm -f "$RESOURCES_TO_COPY" 94 | 95 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] 96 | then 97 | # Find all other xcassets (this unfortunately includes those of path pods and other targets). 98 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) 99 | while read line; do 100 | if [[ $line != "${PODS_ROOT}*" ]]; then 101 | XCASSET_FILES+=("$line") 102 | fi 103 | done <<<"$OTHER_XCASSETS" 104 | 105 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 106 | fi 107 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/Pods/Target Support Files/Pods-FWSegmentedControl/Pods-FWSegmentedControl-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double Pods_FWSegmentedControlVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char Pods_FWSegmentedControlVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/Pods/Target Support Files/Pods-FWSegmentedControl/Pods-FWSegmentedControl.debug.xcconfig: -------------------------------------------------------------------------------- 1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/FWSegmentedControl" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/FWSegmentedControl/FWSegmentedControl.framework/Headers" 5 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 6 | OTHER_LDFLAGS = $(inherited) -framework "FWSegmentedControl" 7 | OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS 8 | PODS_BUILD_DIR = ${BUILD_DIR} 9 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 10 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 11 | PODS_ROOT = ${SRCROOT}/Pods 12 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 13 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/Pods/Target Support Files/Pods-FWSegmentedControl/Pods-FWSegmentedControl.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_FWSegmentedControl { 2 | umbrella header "Pods-FWSegmentedControl-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/Pods/Target Support Files/Pods-FWSegmentedControl/Pods-FWSegmentedControl.release.xcconfig: -------------------------------------------------------------------------------- 1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/FWSegmentedControl" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/FWSegmentedControl/FWSegmentedControl.framework/Headers" 5 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 6 | OTHER_LDFLAGS = $(inherited) -framework "FWSegmentedControl" 7 | OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS 8 | PODS_BUILD_DIR = ${BUILD_DIR} 9 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 10 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 11 | PODS_ROOT = ${SRCROOT}/Pods 12 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 13 | -------------------------------------------------------------------------------- /FWSegmentedControlOCDemo/Test.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Test.swift 3 | // FWSegmentedControl 4 | // 5 | // Created by xfg on 2018/3/16. 6 | // Copyright © 2018年 xfg. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl.xcodeproj/xcuserdata/xfg.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl.xcodeproj/xcuserdata/xfg.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | FWSegmentedControl.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | FWSegmentedControl.xcscheme_^#shared#^_ 13 | 14 | orderHint 15 | 0 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl.xcodeproj/xcuserdata/yechen.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl.xcodeproj/xcuserdata/yechen.xcuserdatad/xcschemes/FWSegmentedControl.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 74 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 95 | 101 | 102 | 103 | 104 | 106 | 107 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl.xcodeproj/xcuserdata/yechen.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | FWSegmentedControl.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 4909B1032086231500588921 16 | 17 | primary 18 | 19 | 20 | 4909B1172086231500588921 21 | 22 | primary 23 | 24 | 25 | 4909B1222086231500588921 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // FWSegmentedControl 4 | // 5 | // Created by xfg on 2018/4/17. 6 | // Copyright © 2018年 xfg. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 18 | 19 | window = UIWindow(frame: UIScreen.main.bounds) 20 | window?.backgroundColor = UIColor.white 21 | window?.rootViewController = FWNavigationController(rootViewController: ViewController()) 22 | window?.makeKeyAndVisible() 23 | 24 | return true 25 | } 26 | 27 | func applicationWillResignActive(_ application: UIApplication) { 28 | // 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. 29 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 30 | } 31 | 32 | func applicationDidEnterBackground(_ application: UIApplication) { 33 | // 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. 34 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 35 | } 36 | 37 | func applicationWillEnterForeground(_ application: UIApplication) { 38 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 39 | } 40 | 41 | func applicationDidBecomeActive(_ application: UIApplication) { 42 | // 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. 43 | } 44 | 45 | func applicationWillTerminate(_ application: UIApplication) { 46 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 47 | } 48 | 49 | 50 | } 51 | 52 | -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/1-selected.imageset/1-selected@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/1-selected.imageset/1-selected@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/1-selected.imageset/1-selected@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/1-selected.imageset/1-selected@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/1-selected.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "1-selected@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "1-selected@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/1.imageset/1@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/1.imageset/1@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/1.imageset/1@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/1.imageset/1@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/1.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "1@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "1@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/2-selected.imageset/2-selected@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/2-selected.imageset/2-selected@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/2-selected.imageset/2-selected@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/2-selected.imageset/2-selected@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/2-selected.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "2-selected@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "2-selected@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/2.imageset/2@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/2.imageset/2@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/2.imageset/2@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/2.imageset/2@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/2.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "2@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "2@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/3-selected.imageset/3-selected@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/3-selected.imageset/3-selected@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/3-selected.imageset/3-selected@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/3-selected.imageset/3-selected@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/3-selected.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "3-selected@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "3-selected@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/3.imageset/3@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/3.imageset/3@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/3.imageset/3@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/3.imageset/3@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/3.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "3@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "3@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/4-selected.imageset/4-selected@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/4-selected.imageset/4-selected@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/4-selected.imageset/4-selected@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/4-selected.imageset/4-selected@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/4-selected.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "4-selected@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "4-selected@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/4.imageset/4@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/4.imageset/4@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/4.imageset/4@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/4.imageset/4@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/4.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "4@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "4@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/5-selected.imageset/5-selected@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/5-selected.imageset/5-selected@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/5-selected.imageset/5-selected@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/5-selected.imageset/5-selected@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/5-selected.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "5-selected@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "5-selected@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/5.imageset/5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/5.imageset/5@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/5.imageset/5@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/5.imageset/5@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/5.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "5@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "5@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/6-selected.imageset/6-selected@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/6-selected.imageset/6-selected@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/6-selected.imageset/6-selected@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/6-selected.imageset/6-selected@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/6-selected.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "6-selected@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "6-selected@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/6.imageset/6@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/6.imageset/6@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/6.imageset/6@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/6.imageset/6@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/6.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "6@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "6@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/7-selected.imageset/7-selected@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/7-selected.imageset/7-selected@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/7-selected.imageset/7-selected@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/7-selected.imageset/7-selected@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/7-selected.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "7-selected@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "7-selected@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/7.imageset/7@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/7.imageset/7@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/7.imageset/7@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/7.imageset/7@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/7.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "7@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "7@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/a-selected.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "a-selected@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "a-selected@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/a-selected.imageset/a-selected@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/a-selected.imageset/a-selected@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/a-selected.imageset/a-selected@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/a-selected.imageset/a-selected@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/a.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "a@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "a@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/a.imageset/a@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/a.imageset/a@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/a.imageset/a@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/a.imageset/a@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/b-selected.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "b-selected@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "b-selected@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/b-selected.imageset/b-selected@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/b-selected.imageset/b-selected@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/b-selected.imageset/b-selected@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/b-selected.imageset/b-selected@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/b.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "b@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "b@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/b.imageset/b@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/b.imageset/b@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/b.imageset/b@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/b.imageset/b@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/c-selected.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "c-selected@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "c-selected@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/c-selected.imageset/c-selected@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/c-selected.imageset/c-selected@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/c-selected.imageset/c-selected@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/c-selected.imageset/c-selected@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/c.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "c@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "c@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/c.imageset/c@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/c.imageset/c@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/c.imageset/c@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/c.imageset/c@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/hm_hot_city.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "hm_hot_city@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "hm_hot_city@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/hm_hot_city.imageset/hm_hot_city@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/hm_hot_city.imageset/hm_hot_city@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/hm_hot_city.imageset/hm_hot_city@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/hm_hot_city.imageset/hm_hot_city@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/hm_hot_city_selected.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "hm_hot_city_selected@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "hm_hot_city_selected@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/hm_hot_city_selected.imageset/hm_hot_city_selected@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/hm_hot_city_selected.imageset/hm_hot_city_selected@2x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/hm_hot_city_selected.imageset/hm_hot_city_selected@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/FWSegmentedControlSwiftDemo/FWSegmentedControl/Assets.xcassets/hm_hot_city_selected.imageset/hm_hot_city_selected@3x.png -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/Base.lproj/LaunchScreen.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 | -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/FWNavigationController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FWNavigationController.swift 3 | // FWSegmentedControl 4 | // 5 | // Created by xfg on 2018/3/29. 6 | // Copyright © 2018年 xfg. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | class FWNavigationController: UINavigationController { 13 | 14 | override func viewDidLoad() { 15 | super.viewDidLoad() 16 | 17 | navigationBar.isTranslucent = false 18 | 19 | self.extendedLayoutIncludesOpaqueBars = false 20 | self.edgesForExtendedLayout = [] 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/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 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIRequiredDeviceCapabilities 26 | 27 | armv7 28 | 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/NewsViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NewsViewController.swift 3 | // FWSegmentedControl 4 | // 5 | // Created by xfg on 2018/4/20. 6 | // Copyright © 2018年 xfg. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | class NewsViewController: UIViewController { 13 | 14 | public var textLabel: UILabel! 15 | 16 | override func viewDidLoad() { 17 | super.viewDidLoad() 18 | 19 | textLabel = UILabel(frame: self.view.bounds) 20 | textLabel.backgroundColor = UIColor(red: CGFloat(arc4random()%256)/255.0, green: CGFloat(arc4random()%256)/255.0, blue: CGFloat(arc4random()%256)/255.0, alpha: 1.0) 21 | textLabel.textColor = UIColor.white 22 | textLabel.textAlignment = .center 23 | self.view.addSubview(textLabel) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/ShoppingViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ShoppingViewController.swift 3 | // FWSegmentedControl 4 | // 5 | // Created by xfg on 2018/4/20. 6 | // Copyright © 2018年 xfg. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | class ShoppingViewController: UIViewController { 13 | 14 | public var textLabel: UILabel! 15 | 16 | override func viewDidLoad() { 17 | super.viewDidLoad() 18 | 19 | textLabel = UILabel(frame: self.view.bounds) 20 | textLabel.backgroundColor = UIColor(red: CGFloat(arc4random()%256)/255.0, green: CGFloat(arc4random()%256)/255.0, blue: CGFloat(arc4random()%256)/255.0, alpha: 1.0) 21 | textLabel.textColor = UIColor.white 22 | textLabel.textAlignment = .center 23 | self.view.addSubview(textLabel) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // FWSegmentedControl 4 | // 5 | // Created by xfg on 2018/3/12. 6 | // Copyright © 2018年 xfg. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | /// segmentedControl字体大小 12 | let kSegmentTitleFont: CGFloat = 13.0 13 | /// segmentedControl左边边距 14 | let kSegmentLeftEdge: CGFloat = 10 15 | 16 | class ViewController: UIViewController, UIScrollViewDelegate { 17 | 18 | /// 是否点击了Segmented的滑块 19 | var isClickedSegmented = false 20 | /// Segmented的滑块起始页 21 | var startPage = 0 22 | 23 | let sectionTitles = ["关注", "游戏", "附近", "体育", "女神范", "运动啦啦", "歌舞", "吃鸡", "户外", "脱口秀"] 24 | 25 | let sectionTitles2 = ["女神", "运动啦啦", "歌舞"] 26 | 27 | let images = [UIImage(named: "1"), 28 | UIImage(named: "2"), 29 | UIImage(named: "3"), 30 | UIImage(named: "4"), 31 | UIImage(named: "5"), 32 | UIImage(named: "6"), 33 | UIImage(named: "7")] 34 | 35 | let selectedImages = [UIImage(named: "1-selected"), 36 | UIImage(named: "2-selected"), 37 | UIImage(named: "3-selected"), 38 | UIImage(named: "4-selected"), 39 | UIImage(named: "5-selected"), 40 | UIImage(named: "6-selected"), 41 | UIImage(named: "7-selected")] 42 | 43 | let imageTitles3 = ["叶子", "椰子啦", "叶紫"] 44 | 45 | let images2 = [UIImage(named: "a"), 46 | UIImage(named: "b"), 47 | UIImage(named: "c")] 48 | 49 | let selectedImages2 = [UIImage(named: "a-selected"), 50 | UIImage(named: "b-selected"), 51 | UIImage(named: "c-selected")] 52 | 53 | /// 例一:默认配置 54 | private lazy var segmentedControl: FWSegmentedControl = { 55 | 56 | let segmentedControl = FWSegmentedControl.segmentedWith(scType: SCType.text, scWidthStyle: SCWidthStyle.fixed, sectionTitleArray: nil, sectionImageArray: nil, sectionSelectedImageArray: nil, frame: CGRect(x: 0, y: 0, width: Int(UIScreen.main.bounds.width), height: 50)) 57 | 58 | segmentedControl.sectionTitleArray = sectionTitles 59 | segmentedControl.scSelectionIndicatorStyle = .fullWidthStripe 60 | 61 | return segmentedControl 62 | }() 63 | 64 | /// 例二:比较常用 65 | private lazy var segmentedControl2: FWSegmentedControl = { 66 | 67 | let segmentedControl = FWSegmentedControl.segmentedWith(scType: SCType.text, scWidthStyle: SCWidthStyle.dynamicFixedSuper, sectionTitleArray: sectionTitles, sectionImageArray: nil, sectionSelectedImageArray: nil, frame: CGRect(x: 0, y: Int(self.segmentedControl.frame.maxY) + 10, width: Int(UIScreen.main.bounds.width), height: 40)) 68 | 69 | segmentedControl.selectedSegmentIndex = 1 70 | 71 | segmentedControl.scSelectionIndicatorStyle = .contentWidthStripe 72 | segmentedControl.segmentEdgeInset = UIEdgeInsets(top: 0, left: kSegmentLeftEdge, bottom: 0, right: kSegmentLeftEdge) 73 | 74 | segmentedControl.selectionIndicatorColor = UIColor.red 75 | segmentedControl.selectionIndicatorHeight = 3 76 | 77 | segmentedControl.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.gray, NSAttributedString.Key.font : UIFont.systemFont(ofSize: kSegmentTitleFont)] 78 | segmentedControl.selectedTitleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.red, NSAttributedString.Key.backgroundColor: UIColor.clear, NSAttributedString.Key.font: UIFont.systemFont(ofSize: kSegmentTitleFont)] 79 | 80 | segmentedControl.autoresizingMask = [.flexibleRightMargin, .flexibleLeftMargin] 81 | 82 | return segmentedControl 83 | }() 84 | 85 | /// 例三:选中标识固定长度 86 | private lazy var segmentedControl3: FWSegmentedControl = { 87 | 88 | let segmentedControl = FWSegmentedControl.segmentedWith(scType: SCType.text, scWidthStyle: SCWidthStyle.dynamicFixedSuper, sectionTitleArray: sectionTitles, sectionImageArray: nil, sectionSelectedImageArray: nil, frame: CGRect(x: 0, y: Int(self.segmentedControl2.frame.maxY) + 10, width: Int(UIScreen.main.bounds.width), height: 40)) 89 | 90 | segmentedControl.selectedSegmentIndex = 1 91 | 92 | segmentedControl.scSelectionIndicatorStyle = .fixedWidthStripe 93 | segmentedControl.segmentEdgeInset = UIEdgeInsets(top: 0, left: kSegmentLeftEdge, bottom: 0, right: kSegmentLeftEdge) 94 | segmentedControl.selectionStripeIndicatorFixedWidth = 20.0 95 | 96 | segmentedControl.selectionIndicatorColor = UIColor.red 97 | segmentedControl.selectionIndicatorHeight = 3 98 | 99 | segmentedControl.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.gray, NSAttributedString.Key.font : UIFont.systemFont(ofSize: kSegmentTitleFont)] 100 | segmentedControl.selectedTitleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.red, NSAttributedString.Key.backgroundColor: UIColor.clear, NSAttributedString.Key.font: UIFont.systemFont(ofSize: kSegmentTitleFont)] 101 | 102 | segmentedControl.autoresizingMask = [.flexibleRightMargin, .flexibleLeftMargin] 103 | 104 | return segmentedControl 105 | }() 106 | 107 | /// 例四:含边框 108 | private lazy var segmentedControl4: FWSegmentedControl = { 109 | 110 | let segmentedControl = FWSegmentedControl.segmentedWith(scType: SCType.text, scWidthStyle: SCWidthStyle.fixed, sectionTitleArray: sectionTitles2, sectionImageArray: nil, sectionSelectedImageArray: nil, frame: CGRect(x: 0, y: Int(self.segmentedControl3.frame.maxY) + 10, width: Int(UIScreen.main.bounds.width), height: 40)) 111 | 112 | segmentedControl.backgroundColor = UIColor.clear 113 | segmentedControl.scSelectionIndicatorStyle = .box 114 | segmentedControl.scSelectionIndicatorLocation = .down 115 | segmentedControl.segmentEdgeInset = UIEdgeInsets(top: 0, left: kSegmentLeftEdge, bottom: 0, right: kSegmentLeftEdge) 116 | 117 | segmentedControl.selectionIndicatorBoxColor = UIColor.green 118 | segmentedControl.selectionIndicatorBoxOpacity = 0.4 119 | segmentedControl.selectionIndicatorBoxFollowEdgeInset = true 120 | segmentedControl.selectionIndicatorHeight = 0 121 | 122 | segmentedControl.scBorderType = [.left, .bottom, .top, .right] 123 | segmentedControl.segmentBorderColor = UIColor.red 124 | segmentedControl.segmentBorderWidth = 2.0 125 | segmentedControl.segmentBackgroundColor = UIColor.white 126 | 127 | segmentedControl.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.gray, NSAttributedString.Key.font : UIFont.systemFont(ofSize: kSegmentTitleFont)] 128 | segmentedControl.selectedTitleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.red, NSAttributedString.Key.backgroundColor: UIColor.clear, NSAttributedString.Key.font: UIFont.systemFont(ofSize: kSegmentTitleFont)] 129 | 130 | segmentedControl.autoresizingMask = .flexibleRightMargin 131 | 132 | return segmentedControl 133 | }() 134 | 135 | /// 例五:选中标识符背景色 136 | private lazy var segmentedControl5: FWSegmentedControl = { 137 | 138 | let segmentedControl = FWSegmentedControl.segmentedWith(scType: SCType.text, scWidthStyle: SCWidthStyle.dynamic, sectionTitleArray: sectionTitles, sectionImageArray: nil, sectionSelectedImageArray: nil, frame: CGRect(x: 0, y: Int(self.segmentedControl4.frame.maxY) + 10, width: Int(UIScreen.main.bounds.width), height: 30)) 139 | 140 | segmentedControl.backgroundColor = UIColor.clear 141 | segmentedControl.scSelectionIndicatorStyle = .box 142 | segmentedControl.scSelectionIndicatorLocation = .down 143 | segmentedControl.segmentEdgeInset = UIEdgeInsets(top: 0, left: 6.0, bottom: 0, right: 6.0) 144 | segmentedControl.segmentBackgroundEdgeInset = UIEdgeInsets(top: 0, left: 15, bottom: 0, right: 15) 145 | 146 | segmentedControl.selectionIndicatorBoxColor = UIColor.red 147 | segmentedControl.selectionIndicatorBoxEdgeInset = UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 10) 148 | segmentedControl.selectionIndicatorBoxFollowEdgeInset = true 149 | segmentedControl.selectionIndicatorHeight = 0 150 | 151 | segmentedControl.enlargetouchesEdgeInset = UIEdgeInsets(top: 5, left: 5, bottom: 5, right: 5) 152 | 153 | segmentedControl.segmentBackgroundCornerRadius = 15 154 | segmentedControl.segmentBackgroundColor = UIColor.white 155 | 156 | segmentedControl.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.black, NSAttributedString.Key.font : UIFont.systemFont(ofSize: kSegmentTitleFont)] 157 | segmentedControl.selectedTitleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white, NSAttributedString.Key.backgroundColor: UIColor.clear, NSAttributedString.Key.font: UIFont.systemFont(ofSize: kSegmentTitleFont)] 158 | 159 | segmentedControl.autoresizingMask = .flexibleRightMargin 160 | 161 | return segmentedControl 162 | }() 163 | 164 | /// 例六:展示图片 165 | private lazy var segmentedControl6: FWSegmentedControl = { 166 | 167 | let segmentedControl = FWSegmentedControl.segmentedWith(scType: SCType.images, scWidthStyle: SCWidthStyle.dynamicFixedSuper, sectionTitleArray: nil, sectionImageArray: images as? [UIImage], sectionSelectedImageArray: selectedImages as? [UIImage], frame: CGRect(x: 0, y: Int(self.segmentedControl5.frame.maxY) + 10, width: Int(UIScreen.main.bounds.width), height: 40)) 168 | 169 | segmentedControl.scSelectionIndicatorStyle = .contentWidthStripe 170 | segmentedControl.scSelectionIndicatorLocation = .up 171 | segmentedControl.segmentEdgeInset = UIEdgeInsets(top: 0, left: kSegmentLeftEdge, bottom: 0, right: kSegmentLeftEdge) 172 | 173 | segmentedControl.selectionIndicatorColor = UIColor.red 174 | segmentedControl.selectionIndicatorHeight = 5 175 | 176 | segmentedControl.verticalDividerEnabled = true 177 | segmentedControl.verticalDividerColor = UIColor.lightGray 178 | segmentedControl.verticalDividerWidth = 1.0 179 | 180 | segmentedControl.autoresizingMask = .flexibleRightMargin 181 | 182 | return segmentedControl 183 | }() 184 | 185 | /// 例七:图文混排 186 | private lazy var segmentedControl7: FWSegmentedControl = { 187 | 188 | let imageTitles5 = ["福建", "直播", "小视频", "", "附近"] 189 | 190 | let sectionSelectedImageDict = [ 191 | 0 : FWSectionImageItem(itemImage: UIImage(named: "hm_hot_city")!, itemSelectedImage: UIImage(named: "hm_hot_city_selected")), 192 | 3 : FWSectionImageItem(itemImage: UIImage(named: "a")!, itemSelectedImage: UIImage(named: "a-selected")), 193 | ] 194 | 195 | let segmentedControl = FWSegmentedControl.segmentedWith(scType: SCType.textImages, scWidthStyle: SCWidthStyle.dynamic, sectionTitleArray: imageTitles5, sectionSelectedImageDict: sectionSelectedImageDict, frame: CGRect(x: 0, y: Int(self.segmentedControl6.frame.maxY) + 10, width: Int(UIScreen.main.bounds.width), height: 40)) 196 | 197 | segmentedControl.scSelectionIndicatorStyle = .fixedWidthStripe 198 | segmentedControl.scSelectionIndicatorLocation = .down 199 | segmentedControl.scImagePosition = .rightOfText 200 | segmentedControl.segmentEdgeInset = UIEdgeInsets(top: 0, left: kSegmentLeftEdge, bottom: 0, right: kSegmentLeftEdge) 201 | 202 | segmentedControl.selectionIndicatorColor = UIColor.red 203 | segmentedControl.selectionIndicatorHeight = 3 204 | segmentedControl.selectionIndicatorFollowText = true 205 | 206 | segmentedControl.textImageSpacing = 4 207 | 208 | segmentedControl.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.gray, NSAttributedString.Key.font : UIFont.systemFont(ofSize: kSegmentTitleFont)] 209 | segmentedControl.selectedTitleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.red, NSAttributedString.Key.backgroundColor: UIColor.clear, NSAttributedString.Key.font: UIFont.systemFont(ofSize: kSegmentTitleFont)] 210 | 211 | segmentedControl.autoresizingMask = .flexibleRightMargin 212 | 213 | return segmentedControl 214 | }() 215 | 216 | /// 例八:图文结合(纵向) 217 | private lazy var segmentedControl8: FWSegmentedControl = { 218 | 219 | let segmentedControl = FWSegmentedControl.segmentedWith(scType: SCType.textImages, scWidthStyle: SCWidthStyle.fixed, sectionTitleArray: imageTitles3, sectionImageArray: images2 as? [UIImage], sectionSelectedImageArray: selectedImages2 as? [UIImage], frame: CGRect(x: 0, y: Int(self.segmentedControl7.frame.maxY) + 10, width: Int(UIScreen.main.bounds.width), height: 50)) 220 | 221 | segmentedControl.scSelectionIndicatorStyle = .arrowDown 222 | segmentedControl.scSelectionIndicatorLocation = .down 223 | segmentedControl.scImagePosition = .aboveText 224 | segmentedControl.segmentEdgeInset = UIEdgeInsets(top: 0, left: kSegmentLeftEdge, bottom: 0, right: kSegmentLeftEdge) 225 | 226 | segmentedControl.selectionIndicatorColor = UIColor.red 227 | segmentedControl.selectionIndicatorHeight = 5 228 | 229 | segmentedControl.verticalDividerEnabled = true 230 | segmentedControl.verticalDividerColor = UIColor.lightGray 231 | segmentedControl.verticalDividerWidth = 2.0 232 | 233 | segmentedControl.textImageSpacing = 2.0 234 | 235 | segmentedControl.arrowWidth = 15 236 | 237 | segmentedControl.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.gray, NSAttributedString.Key.font : UIFont.systemFont(ofSize: kSegmentTitleFont)] 238 | segmentedControl.selectedTitleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.red, NSAttributedString.Key.backgroundColor: UIColor.clear, NSAttributedString.Key.font: UIFont.systemFont(ofSize: kSegmentTitleFont)] 239 | 240 | segmentedControl.autoresizingMask = .flexibleRightMargin 241 | 242 | return segmentedControl 243 | }() 244 | 245 | /// 例九:图文结合(横向),与scrollView结合使用 246 | private lazy var segmentedControl9: FWSegmentedControl = { 247 | 248 | let segmentedControl = FWSegmentedControl.segmentedWith(scType: SCType.textImages, scWidthStyle: SCWidthStyle.dynamicFixedSuper, sectionTitleArray: imageTitles3, sectionImageArray: images2 as? [UIImage], sectionSelectedImageArray: selectedImages2 as? [UIImage], frame: CGRect(x: 0, y: Int(self.segmentedControl8.frame.maxY) + 10, width: Int(UIScreen.main.bounds.width), height: 40)) 249 | 250 | segmentedControl.scSelectionIndicatorStyle = .fullWidthStripe 251 | segmentedControl.scSelectionIndicatorLocation = .down 252 | segmentedControl.scImagePosition = .rightOfText 253 | segmentedControl.segmentEdgeInset = UIEdgeInsets(top: 0, left: kSegmentLeftEdge, bottom: 0, right: kSegmentLeftEdge) 254 | 255 | segmentedControl.selectionIndicatorColor = UIColor.red 256 | segmentedControl.selectionIndicatorHeight = 3 257 | 258 | segmentedControl.verticalDividerEnabled = true 259 | segmentedControl.verticalDividerColor = UIColor.lightGray 260 | segmentedControl.verticalDividerWidth = 1.0 261 | 262 | segmentedControl.textImageSpacing = 4 263 | 264 | segmentedControl.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.gray, NSAttributedString.Key.font : UIFont.systemFont(ofSize: kSegmentTitleFont)] 265 | segmentedControl.selectedTitleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.red, NSAttributedString.Key.backgroundColor: UIColor.clear, NSAttributedString.Key.font: UIFont.systemFont(ofSize: kSegmentTitleFont)] 266 | 267 | segmentedControl.autoresizingMask = .flexibleRightMargin 268 | 269 | segmentedControl.indexChangeBlock = { [weak self] index in 270 | self?.isClickedSegmented = true 271 | self?.scrollView.scrollRectToVisible(CGRect(x: (self?.view.bounds.width)! * CGFloat(index), y: 0, width: (self?.view.bounds.width)!, height: (self?.scrollView.frame.height)!), animated: true) 272 | } 273 | 274 | return segmentedControl 275 | }() 276 | 277 | lazy var scrollView: UIScrollView = { 278 | 279 | let scrollView = UIScrollView(frame: CGRect(x: 0, y: self.segmentedControl9.frame.maxY, width: self.view.frame.width, height: self.view.frame.height-self.segmentedControl9.frame.maxY)) 280 | scrollView.backgroundColor = UIColor.clear 281 | scrollView.delegate = self 282 | scrollView.isPagingEnabled = true 283 | scrollView.showsHorizontalScrollIndicator = false 284 | scrollView.bounces = false 285 | scrollView.contentSize = CGSize(width: self.view.bounds.width * CGFloat(imageTitles3.count), height: self.view.bounds.height-self.segmentedControl9.frame.maxY) 286 | scrollView.scrollRectToVisible(CGRect(x: 0, y: 0, width: self.view.bounds.width, height: scrollView.frame.height), animated: false) 287 | return scrollView 288 | }() 289 | 290 | override func viewDidLoad() { 291 | super.viewDidLoad() 292 | self.view.backgroundColor = UIColor.lightGray 293 | self.navigationItem.title = "FWSegmentedControl" 294 | self.edgesForExtendedLayout = [] 295 | 296 | self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "多级联动>", style: .plain, target: self, action: #selector(goNextVC)) 297 | 298 | self.view.addSubview(self.segmentedControl) 299 | self.view.addSubview(self.segmentedControl2) 300 | self.view.addSubview(self.segmentedControl3) 301 | self.view.addSubview(self.segmentedControl4) 302 | self.view.addSubview(self.segmentedControl5) 303 | self.view.addSubview(self.segmentedControl6) 304 | self.view.addSubview(self.segmentedControl7) 305 | self.view.addSubview(self.segmentedControl8) 306 | self.view.addSubview(self.segmentedControl9) 307 | self.view.addSubview(self.scrollView) 308 | 309 | self.scrollView.addSubview(self.setupUIView(index: 0)) 310 | self.scrollView.addSubview(self.setupUIView(index: 1)) 311 | self.scrollView.addSubview(self.setupUIView(index: 2)) 312 | } 313 | 314 | override func viewWillAppear(_ animated: Bool) { 315 | super.viewWillAppear(animated) 316 | 317 | self.segmentedControl9.setSelectedSegmentIndex(index: 2, animated: true) 318 | } 319 | } 320 | 321 | extension ViewController { 322 | 323 | func setupUIView(index: Int) -> UILabel { 324 | 325 | let label = UILabel(frame: CGRect(x: self.view.frame.width * CGFloat(index), y: 0, width: self.view.frame.width, height: self.scrollView.frame.height)) 326 | label.backgroundColor = UIColor(red: CGFloat(arc4random()%256)/255.0, green: CGFloat(arc4random()%256)/255.0, blue: CGFloat(arc4random()%256)/255.0, alpha: 1.0) 327 | label.textColor = UIColor.white 328 | label.text = self.imageTitles3[index] 329 | label.textAlignment = .center 330 | return label 331 | } 332 | 333 | func scrollViewDidScroll(_ scrollView: UIScrollView) { 334 | 335 | if isClickedSegmented == false { 336 | let pageWidth = scrollView.frame.width 337 | let tmpPage = scrollView.contentOffset.x / pageWidth 338 | let tmpPage2 = scrollView.contentOffset.x / pageWidth 339 | let page = tmpPage2-tmpPage>=0.5 ? tmpPage+1 : tmpPage 340 | if startPage != Int(page) { 341 | self.segmentedControl9.setSelectedSegmentIndex(index: Int(page), animated: true) 342 | startPage = Int(page) 343 | } 344 | } 345 | } 346 | 347 | func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { 348 | let pageWidth = scrollView.frame.width 349 | let page = scrollView.contentOffset.x / pageWidth 350 | self.isClickedSegmented = false 351 | self.segmentedControl9.setSelectedSegmentIndex(index: Int(page), animated: true) 352 | } 353 | 354 | @objc func goNextVC() { 355 | 356 | self.navigationController?.pushViewController(ViewController2(), animated: true) 357 | } 358 | } 359 | 360 | -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControl/ViewController2.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController2.swift 3 | // FWSegmentedControl 4 | // 5 | // Created by xfg on 2018/3/20. 6 | // Copyright © 2018年 xfg. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | let segmentedControlHeight: CGFloat = 40.0 13 | let segmentedControl2Height: CGFloat = 40.0 14 | 15 | 16 | class ViewController2: UIViewController, UIScrollViewDelegate { 17 | 18 | let sectionTitles = ["新闻", "购物"] 19 | let sectionTitles2 = ["精选", "视频", "军事", "要闻"] 20 | let sectionTitles3 = ["电器", "数码", "服饰", "家具"] 21 | 22 | var segmentedControlArray: [FWSegmentedControl] = [] 23 | 24 | 25 | private lazy var segmentedControl: FWSegmentedControl = { 26 | 27 | let segmentedControl = FWSegmentedControl.segmentedWith(scType: SCType.text, scWidthStyle: SCWidthStyle.dynamicFixedSuper, sectionTitleArray: sectionTitles, sectionImageArray: nil, sectionSelectedImageArray: nil, frame: CGRect(x: 0, y: 0, width: Int(UIScreen.main.bounds.width), height: Int(segmentedControlHeight))) 28 | 29 | segmentedControl.scSelectionIndicatorStyle = .fullWidthStripe 30 | segmentedControl.scSelectionIndicatorLocation = .down 31 | segmentedControl.segmentEdgeInset = UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 10) 32 | 33 | segmentedControl.selectionIndicatorColor = UIColor.red 34 | segmentedControl.selectionIndicatorHeight = 3 35 | 36 | segmentedControl.verticalDividerEnabled = true 37 | segmentedControl.verticalDividerColor = UIColor.lightGray 38 | segmentedControl.verticalDividerWidth = 1.0 39 | 40 | segmentedControl.scBorderType = .bottom 41 | segmentedControl.segmentBorderColor = UIColor.lightGray 42 | segmentedControl.segmentBorderWidth = 1.0 43 | 44 | segmentedControl.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.gray, NSAttributedString.Key.font : UIFont.systemFont(ofSize: CGFloat(13.0))] 45 | segmentedControl.selectedTitleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.red, NSAttributedString.Key.backgroundColor: UIColor.clear, NSAttributedString.Key.font: UIFont.systemFont(ofSize: CGFloat(13.0))] 46 | 47 | segmentedControl.autoresizingMask = .flexibleRightMargin 48 | 49 | return segmentedControl 50 | }() 51 | 52 | lazy var scrollView: UIScrollView = { 53 | 54 | let scrollView = UIScrollView.init(frame: CGRect(x: 0, y: self.segmentedControl.frame.maxY, width: self.view.bounds.width, height: self.view.bounds.height - self.segmentedControl.frame.maxY)) 55 | scrollView.tag = 0 56 | scrollView.backgroundColor = UIColor.clear 57 | scrollView.delegate = self 58 | scrollView.isPagingEnabled = true 59 | scrollView.showsHorizontalScrollIndicator = false 60 | scrollView.bounces = false 61 | scrollView.contentSize = CGSize(width: self.view.bounds.width * CGFloat(sectionTitles.count), height: segmentedControl2Height) 62 | scrollView.scrollRectToVisible(CGRect(x: 0, y: 0, width: self.view.bounds.width, height: scrollView.frame.height), animated: false) 63 | return scrollView 64 | }() 65 | 66 | override func viewDidLoad() { 67 | super.viewDidLoad() 68 | self.view.backgroundColor = UIColor.lightGray 69 | self.edgesForExtendedLayout = [] 70 | 71 | self.view.addSubview(self.segmentedControl) 72 | self.view.addSubview(self.scrollView) 73 | 74 | self.segmentedControl.indexChangeBlock = { [weak self] index in 75 | self?.scrollView.scrollRectToVisible(CGRect(x: (self?.view.bounds.width)! * CGFloat(index), y: 0, width: (self?.view.bounds.width)!, height: (self?.scrollView.frame.height)!), animated: true) 76 | } 77 | 78 | let segmentedControl2 = self.setupSegmentedControl(index: 0, sectionTitleArray: self.sectionTitles2) 79 | let segmentedControl3 = self.setupSegmentedControl(index: 1, sectionTitleArray: self.sectionTitles3) 80 | 81 | self.segmentedControlArray.append(segmentedControl2) 82 | self.segmentedControlArray.append(segmentedControl3) 83 | 84 | self.scrollView.addSubview(segmentedControl2) 85 | self.scrollView.addSubview(segmentedControl3) 86 | 87 | } 88 | } 89 | 90 | extension ViewController2 { 91 | 92 | func setupSegmentedControl(index: Int, sectionTitleArray: [String]) -> FWSegmentedControl { 93 | 94 | let segmentedControl2 = FWSegmentedControl.segmentedWith(scType: SCType.text, scWidthStyle: SCWidthStyle.dynamicFixedSuper, sectionTitleArray: sectionTitleArray, sectionImageArray: nil, sectionSelectedImageArray: nil, frame: CGRect(x: Int(self.view.frame.width * CGFloat(index)), y: 0, width: Int(UIScreen.main.bounds.width), height: Int(segmentedControl2Height))) 95 | 96 | segmentedControl2.scSelectionIndicatorStyle = .fullWidthStripe 97 | segmentedControl2.scSelectionIndicatorLocation = .down 98 | segmentedControl2.segmentEdgeInset = UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 10) 99 | 100 | segmentedControl2.selectionIndicatorColor = UIColor.red 101 | segmentedControl2.selectionIndicatorHeight = 3 102 | 103 | segmentedControl2.verticalDividerEnabled = true 104 | segmentedControl2.verticalDividerColor = UIColor.lightGray 105 | segmentedControl2.verticalDividerWidth = 1.0 106 | 107 | segmentedControl2.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.gray, NSAttributedString.Key.font : UIFont.systemFont(ofSize: CGFloat(13.0))] 108 | segmentedControl2.selectedTitleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.red, NSAttributedString.Key.backgroundColor: UIColor.clear, NSAttributedString.Key.font: UIFont.systemFont(ofSize: CGFloat(13.0))] 109 | 110 | segmentedControl2.autoresizingMask = .flexibleRightMargin 111 | 112 | let scrollView2 = self.setupScrollView(index: index, sectionTitleArray: sectionTitleArray) 113 | self.scrollView.addSubview(scrollView2) 114 | 115 | segmentedControl2.indexChangeBlock = { [weak self] index in 116 | scrollView2.scrollRectToVisible(CGRect(x: (self?.view.bounds.width)! * CGFloat(index), y: 0, width: (self?.view.bounds.width)!, height: scrollView2.frame.height), animated: true) 117 | } 118 | 119 | return segmentedControl2 120 | } 121 | 122 | func setupScrollView(index: Int, sectionTitleArray: [String]) -> UIScrollView { 123 | 124 | let scrollView2 = UIScrollView.init(frame: CGRect(x: self.view.frame.width * CGFloat(index), y: segmentedControl2Height, width: self.view.bounds.width, height: self.view.bounds.height-self.segmentedControl.frame.maxY - segmentedControl2Height)) 125 | scrollView2.tag = 1 + index 126 | scrollView2.backgroundColor = UIColor.clear 127 | scrollView2.delegate = self 128 | scrollView2.isPagingEnabled = true 129 | scrollView2.showsHorizontalScrollIndicator = false 130 | scrollView2.bounces = false 131 | scrollView2.contentSize = CGSize(width: self.view.bounds.width * CGFloat(sectionTitleArray.count), height: self.segmentedControl.frame.height) 132 | scrollView2.scrollRectToVisible(CGRect(x: 0, y: 0, width: self.view.bounds.width, height: scrollView2.frame.height), animated: false) 133 | 134 | var tmpIndex = 0 135 | for title in sectionTitleArray { 136 | 137 | scrollView2.addSubview(self.setupVC(firstIndex: index, secondIndex: tmpIndex, title: title)) 138 | tmpIndex += 1 139 | } 140 | 141 | return scrollView2 142 | } 143 | 144 | func setupVC(firstIndex: Int, secondIndex: Int, title: String) -> UIView { 145 | 146 | if firstIndex == 0 { 147 | let newsVC = NewsViewController() 148 | newsVC.view.frame = CGRect(x: self.view.frame.width * CGFloat(secondIndex), y: 0, width: self.view.frame.width, height: self.scrollView.frame.height) 149 | newsVC.textLabel.text = title 150 | 151 | return newsVC.view 152 | } else { 153 | let shoppingVC = ShoppingViewController() 154 | shoppingVC.view.frame = CGRect(x: self.view.frame.width * CGFloat(secondIndex), y: 0, width: self.view.frame.width, height: self.scrollView.frame.height) 155 | shoppingVC.textLabel.text = title 156 | 157 | return shoppingVC.view 158 | } 159 | } 160 | 161 | // func scrollViewDidScroll(_ scrollView: UIScrollView) { 162 | // 163 | // let pageWidth = scrollView.frame.width 164 | // let tmpPage = scrollView.contentOffset.x / pageWidth 165 | // let tmpPage2 = scrollView.contentOffset.x / pageWidth 166 | // let page = tmpPage2-tmpPage>=0.5 ? tmpPage+1 : tmpPage 167 | // 168 | // if scrollView.tag == 0 { 169 | // self.segmentedControl.setSelectedSegmentIndex(index: Int(page), animated: true) 170 | // } else { 171 | // let segmentedControl = segmentedControlArray[scrollView.tag-1] 172 | // segmentedControl.setSelectedSegmentIndex(index: Int(page), animated: true) 173 | // } 174 | // } 175 | 176 | func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { 177 | 178 | let pageWidth = scrollView.frame.width 179 | let page = scrollView.contentOffset.x / pageWidth 180 | 181 | if scrollView.tag == 0 { 182 | self.segmentedControl.setSelectedSegmentIndex(index: Int(page), animated: true) 183 | } else { 184 | let segmentedControl = segmentedControlArray[scrollView.tag-1] 185 | segmentedControl.setSelectedSegmentIndex(index: Int(page), animated: true) 186 | } 187 | } 188 | } 189 | 190 | -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControlTests/FWSegmentedControlTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FWSegmentedControlTests.swift 3 | // FWSegmentedControlTests 4 | // 5 | // Created by xfg on 2018/4/17. 6 | // Copyright © 2018年 xfg. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import FWSegmentedControl 11 | 12 | class FWSegmentedControlTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | // Use XCTAssert and related functions to verify your tests produce the correct results. 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControlTests/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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControlUITests/FWSegmentedControlUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FWSegmentedControlUITests.swift 3 | // FWSegmentedControlUITests 4 | // 5 | // Created by xfg on 2018/4/17. 6 | // Copyright © 2018年 xfg. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class FWSegmentedControlUITests: XCTestCase { 12 | 13 | override func setUp() { 14 | super.setUp() 15 | 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | 18 | // In UI tests it is usually best to stop immediately when a failure occurs. 19 | continueAfterFailure = false 20 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 21 | XCUIApplication().launch() 22 | 23 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 24 | } 25 | 26 | override func tearDown() { 27 | // Put teardown code here. This method is called after the invocation of each test method in the class. 28 | super.tearDown() 29 | } 30 | 31 | func testExample() { 32 | // Use recording to get started writing UI tests. 33 | // Use XCTAssert and related functions to verify your tests produce the correct results. 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /FWSegmentedControlSwiftDemo/FWSegmentedControlUITests/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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [2018年] [夏福根] 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ![](https://github.com/choiceyou/FWSegmentedControl/blob/master/%E6%95%88%E6%9E%9C/FWSegmentedControl.png) 2 | 3 | [![Platform](http://img.shields.io/badge/platform-iOS-blue.svg?style=flat)](http://cocoapods.org/?q=FWSegmentedControl)  4 | ![Language](https://img.shields.io/badge/language-swift-orange.svg?style=flat)  5 | [![License](http://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/choiceyou/FWSegmentedControl/blob/master/FWSegmentedControl/LICENSE) 6 | 7 | 8 | 9 | ## 支持pod导入: 10 | 11 | ```cocoaPods 12 | use_frameworks! 13 | pod 'FWSegmentedControl' 14 | 注意: 15 | 1、如出现 [!] Unable to find a specification for 'FWSegmentedControl' 错误 或 看不到最新的版本, 16 | 可执行 pod repo update 命令更新一下本地pod仓库。 17 | 2、use_frameworks! 的使用: 18 | (1)纯OC项目中,通过cocoapods导入OC库时,一般都不使用use_frameworks! 19 | (2)纯swift项目中,通过cocoapods导入swift库时,必须使用use_frameworks! 20 | (3)只要是通过cocoapods导入swift库时,都必须使用use_frameworks! 21 | (4)使用动态链接库dynamic frameworks时,必须使用use_frameworks! 22 | ``` 23 | 24 | 25 | ## 可设置参数: 26 | ```参数 27 | /// 标题 28 | @objc public var sectionTitleArray: [String]? 29 | /// 图片 30 | @objc public var sectionImageArray: [UIImage]? 31 | /// 选中图片 32 | @objc public var sectionSelectedImageArray: [UIImage]? 33 | 34 | /// segment类型 35 | @objc public var scType = SCType.text 36 | /// segment宽度 37 | @objc public var scWidthStyle = SCWidthStyle.fixed 38 | /// 图片相对于文字的位置 39 | @objc public var scImagePosition: SCImagePosition = .leftOfText 40 | /// 选中标识符类型 41 | @objc public var scSelectionIndicatorStyle = SCSelectionIndicatorStyle.contentWidthStripe 42 | /// 选中标识符位置 43 | @objc public var scSelectionIndicatorLocation = SCSelectionIndicatorLocation.down 44 | /// 边框类型 45 | public var scBorderType: SCBorderType = .none 46 | 47 | /// 选中标识符高度,注意:self.scSelectionIndicatorStyle == .box || self.scSelectionIndicatorStyle == .none 时无效 48 | @objc public var selectionIndicatorHeight: CGFloat = 3.0 49 | /// 选中标识符,当 SCSelectionIndicatorLocation == up 时,底部edge无效;反之,顶部edge无效; 50 | @objc public var selectionIndicatorEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0) 51 | /// 选中标识符颜色 52 | @objc public var selectionIndicatorColor = UIColor.red 53 | @objc public var selectionIndicatorBoxColor = UIColor.gray 54 | 55 | /// 滑动或者选中回调 56 | @objc public var indexChangeBlock: SCIndexChangeBlock? 57 | /// 标题NSAttributedString回调 58 | @objc public var titleFormatterBlock: SCTitleFormatterBlock? 59 | /// segment的Inset属性 60 | @objc public var segmentEdgeInset = UIEdgeInsetsMake(0, 5, 0, 5) 61 | @objc public var enlargeEdgeInset = UIEdgeInsetsMake(0, 0, 0, 0) 62 | 63 | /// 未选中的标题属性 64 | @objc public var titleTextAttributes: [NSAttributedStringKey: Any]? 65 | /// 选中的标题属性 66 | @objc public var selectedTitleTextAttributes: [NSAttributedStringKey: Any]? 67 | 68 | /// 是否可以拖动 69 | @objc public var userDraggable = true 70 | /// 是否可以点击 71 | @objc public var touchEnabled = true 72 | 73 | /// segment的边框颜色 74 | @objc public var segmentBorderColor = UIColor.black 75 | /// segment的边框大小 76 | @objc public var segmentBorderWidth: CGFloat = 1.0 77 | 78 | /// 选中或者滑动时是否需要动画 79 | @objc public var shouldAnimateUserSelection = true 80 | 81 | /// 选中标识符为箭头的宽度 82 | @objc public var arrowWidth: CGFloat = 6.0 83 | 84 | /// 选中表示符为box时的opacity值 85 | @objc public var selectionIndicatorBoxOpacity: CGFloat = 0.2 86 | 87 | /// segment之间的间隔竖线的宽度 88 | @objc public var verticalDividerWidth: CGFloat = 1.0 89 | /// 是否需要segment之间的间隔竖线 90 | @objc public var verticalDividerEnabled = false 91 | /// segment之间的间隔竖线的颜色 92 | @objc public var verticalDividerColor = UIColor.black 93 | 94 | /// 选中标识符滑动的时间 95 | @objc public var indicatorAnimatedTimes: CFTimeInterval = 0.15 96 | 97 | /// self.scType == .textImages 时,文字、图片的间隔 98 | @objc public var textImageSpacing: CGFloat = 4.0 99 | 100 | /// 选中项的下标 101 | @objc public var selectedSegmentIndex: Int = 0 102 | ``` 103 | 104 | 105 | 106 | ## 简单使用:(注:可下载demo具体查看,分别有OC、Swift的demo) 107 | 108 | ```swift 109 | /// 类初始化方法 110 | /// 111 | /// - Parameters: 112 | /// - scType: segment类型 113 | /// - sectionTitleArray: 标题,可传nil,后续再设置 114 | /// - sectionImageArray: 图片,可传nil,后续再设置 115 | /// - sectionSelectedImageArray: 选中图片,可传nil,后续再设置 116 | /// - frame: frame 117 | @objc open class func segmentedWith(scType: SCType, 118 | scWidthStyle: SCWidthStyle, 119 | sectionTitleArray: [String]?, 120 | sectionImageArray: [UIImage]?, 121 | sectionSelectedImageArray: [UIImage]?, 122 | frame: CGRect) -> FWSegmentedControl 123 | ``` 124 | 125 | ### OC: 126 | ```oc 127 | [FWSegmentedControl segmentedWithScType: SCTypeText 128 | scWidthStyle: SCWidthStyleDynamicFixedSuper 129 | sectionTitleArray: @[@"关注", @"游戏", @"附近"] 130 | sectionImageArray: nil 131 | sectionSelectedImageArray: nil 132 | frame: CGRectMake(0, 40, self.view.frame.size.width, 50)]; 133 | ``` 134 | 135 | 136 | ### Swift:
137 | ```swift 138 | FWSegmentedControl.segmentedWith(scType: SCType.text, 139 | scWidthStyle: SCWidthStyle.fixed, 140 | sectionTitleArray: ["关注", "游戏", "附近"], 141 | sectionImageArray: nil, 142 | sectionSelectedImageArray: nil, 143 | frame: CGRect(x: 0, y: 40, width: Int(UIScreen.main.bounds.width), height: 50)) 144 | 145 | ``` 146 | 147 | 148 | 149 | ## 效果: 150 | 151 | ![](https://github.com/choiceyou/FWSegmentedControl/blob/master/%E6%95%88%E6%9E%9C/%E7%A4%BA%E4%BE%8B1.gif) 152 | ![](https://github.com/choiceyou/FWSegmentedControl/blob/master/%E6%95%88%E6%9E%9C/%E7%A4%BA%E4%BE%8B2.gif) 153 | 154 | 155 | 156 | ## 注意点: 157 | 158 | 一、本UI库是用Swift4.0编写的,所以安装或者拖入文件后需要把对应的Swift设置为4.0版本:
159 | (1)pod安装方式:![](https://github.com/choiceyou/FWSegmentedControl/blob/master/%E6%95%88%E6%9E%9C/%E8%AE%BE%E7%BD%AE1.jpg) 160 | (2)文件拖入方式:Targets --> Build Setting 做相同的设置 161 | 162 | 二、如果是文件拖入方式,需要设置OC、Swift混编等,相关问题网上有很多解答,我这边就不再重复了 163 | 164 | 165 | 166 | ## 更新记录: 167 | 168 | • v2.1.7: 169 | - [x] 添加:sectionSelectedImageDict,使得在一个FWSegmentedControl中支持图片+文字、图片、文字的混排形式; 170 | - [x] 选中标识符可设置圆角,默认圆角值为:1.5f; 171 | - [x] 新增已经选中了某个index后再次点击的回调:SCIndexSecondClickedBlock; 172 | - [x] 修复segmentEdgeInset位置右移的问题; 173 | - [x] 更多细节调整; 174 | 175 | 176 | 177 | ## 结尾语: 178 | 179 | - 使用过程中发现bug请issues或加入FW问题反馈群:670698309(此群只接受FW相关组件问题); 180 | - 有新的需求欢迎提出; 181 | 182 | -------------------------------------------------------------------------------- /效果/FWSegmentedControl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/效果/FWSegmentedControl.png -------------------------------------------------------------------------------- /效果/示例1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/效果/示例1.gif -------------------------------------------------------------------------------- /效果/示例2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/效果/示例2.gif -------------------------------------------------------------------------------- /效果/设置1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/choiceyou/FWSegmentedControl/5424f0b64fa4614f9d39300f3fb76596a8988bd1/效果/设置1.jpg --------------------------------------------------------------------------------