├── IMG_1850.JPG ├── WZBSwitch.gif ├── WZBSwitch - demo.xcodeproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── project.pbxproj ├── WZBSwitch - demo ├── ViewController.h ├── AppDelegate.h ├── main.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Info.plist ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── AppDelegate.m ├── ViewController.m └── WZBSwitch │ ├── WZBSwitch.h │ └── WZBSwitch.m ├── WZBSwitch - demoTests ├── Info.plist └── WZBSwitch___demoTests.m ├── WZBSwitch - demoUITests ├── Info.plist └── WZBSwitch___demoUITests.m ├── LICENSE ├── .gitignore └── README.md /IMG_1850.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WZBbiao/WZBSwitch/HEAD/IMG_1850.JPG -------------------------------------------------------------------------------- /WZBSwitch.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WZBbiao/WZBSwitch/HEAD/WZBSwitch.gif -------------------------------------------------------------------------------- /WZBSwitch - demo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /WZBSwitch - demo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // WZBSwitch - demo 4 | // 5 | // Created by WZB on 2016/10/14. 6 | // Copyright © 2016年 normal. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | @end 14 | 15 | -------------------------------------------------------------------------------- /WZBSwitch - demo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // WZBSwitch - demo 4 | // 5 | // Created by normal on 2016/10/14. 6 | // Copyright © 2016年 normal. 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 | -------------------------------------------------------------------------------- /WZBSwitch - demo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // WZBSwitch - demo 4 | // 5 | // Created by normal on 2016/10/14. 6 | // Copyright © 2016年 normal. 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 | -------------------------------------------------------------------------------- /WZBSwitch - demoTests/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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /WZBSwitch - demoUITests/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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /WZBSwitch - demo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /WZBSwitch - demoTests/WZBSwitch___demoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // WZBSwitch___demoTests.m 3 | // WZBSwitch - demoTests 4 | // 5 | // Created by normal on 2016/10/14. 6 | // Copyright © 2016年 normal. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface WZBSwitch___demoTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation WZBSwitch___demoTests 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 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 WZBbiao 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 | -------------------------------------------------------------------------------- /WZBSwitch - demo/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 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /WZBSwitch - demoUITests/WZBSwitch___demoUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // WZBSwitch___demoUITests.m 3 | // WZBSwitch - demoUITests 4 | // 5 | // Created by normal on 2016/10/14. 6 | // Copyright © 2016年 normal. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface WZBSwitch___demoUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation WZBSwitch___demoUITests 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 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | *.dSYM.zip 28 | *.dSYM 29 | 30 | # CocoaPods 31 | # 32 | # We recommend against adding the Pods directory to your .gitignore. However 33 | # you should judge for yourself, the pros and cons are mentioned at: 34 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 35 | # 36 | # Pods/ 37 | 38 | # Carthage 39 | # 40 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 41 | # Carthage/Checkouts 42 | 43 | Carthage/Build 44 | 45 | # fastlane 46 | # 47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 48 | # screenshots whenever they are needed. 49 | # For more information about the recommended setup visit: 50 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 51 | 52 | fastlane/report.xml 53 | fastlane/screenshots 54 | 55 | #Code Injection 56 | # 57 | # After new code Injection tools there's a generated folder /iOSInjectionProject 58 | # https://github.com/johnno1962/injectionforxcode 59 | 60 | iOSInjectionProject/ 61 | -------------------------------------------------------------------------------- /WZBSwitch - demo/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 | -------------------------------------------------------------------------------- /WZBSwitch - demo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /WZBSwitch - demo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // WZBSwitch - demo 4 | // 5 | // Created by normal on 2016/10/14. 6 | // Copyright © 2016年 normal. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // 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. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // 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. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // 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. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 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 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /WZBSwitch - demo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // WZBSwitch - demo 4 | // 5 | // Created by WZB on 2016/10/14. 6 | // Copyright © 2016年 normal. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "WZBSwitch.h" 11 | 12 | #define WZBColor(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0] 13 | 14 | @interface ViewController () 15 | 16 | @end 17 | 18 | @implementation ViewController 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | /** 初始化方法 23 | * switchValueChange: 开关状态改变回调block 24 | */ 25 | WZBSwitch *switchView = [[WZBSwitch alloc] initWithFrame:CGRectMake(100, 100, 50, 25) switchValueChanged:^(WZBSwitch *swith, BOOL on) { 26 | // do someing 27 | NSLog(@"on----%d", on); 28 | }]; 29 | [self.view addSubview:switchView]; 30 | // delegate 31 | switchView.delegate = self; 32 | 33 | // 设置所有颜色 34 | // [switchView setUpAllColors:^NSDictionary *(UIColor *__autoreleasing *onTintColor, UIColor *__autoreleasing *onBackgroundColor, UIColor *__autoreleasing *offTintColor, UIColor *__autoreleasing *offBackgroundColor, UIColor *__autoreleasing *tintColor) { 35 | // // 可以通过这种方法设置需要设置的颜色 36 | // *onTintColor = [UIColor redColor]; 37 | // *onBackgroundColor = [UIColor blueColor]; 38 | // *offTintColor = [UIColor greenColor]; 39 | // *offBackgroundColor = [UIColor grayColor]; 40 | // *tintColor = [UIColor blackColor]; 41 | // return nil; 42 | // }]; 43 | [switchView setUpAllColors:^NSDictionary *(UIColor *__autoreleasing *onTintColor, UIColor *__autoreleasing *onBackgroundColor, UIColor *__autoreleasing *offTintColor, UIColor *__autoreleasing *offBackgroundColor, UIColor *__autoreleasing *tintColor) { 44 | // 也可以通过这种方法设置需要设置的颜色 45 | return @{OnTintColor : WZBColor(234, 67, 53), OnBackgroundColor : WZBColor(244, 161, 154), OffTintColor : WZBColor(255, 255, 255), OffBackgroundColor : WZBColor(214, 214, 214), TintColor : [UIColor colorWithRed:0.8252 green:0.8252 blue:0.8252 alpha:1.0]}; 46 | }]; 47 | } 48 | 49 | #pragma mark - WZBSwitchDelegate 50 | - (void)switchValueChange:(WZBSwitch *)swith on:(BOOL)on { 51 | // do someing 52 | } 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /WZBSwitch - demo/WZBSwitch/WZBSwitch.h: -------------------------------------------------------------------------------- 1 | // 2 | // WZBSwitch.h 3 | // 自定义开关 4 | // 5 | // Created by WZB on 16/7/27. 6 | // Copyright © 2016年 王振标. All rights reserved. 7 | // 8 | 9 | 10 | #import 11 | 12 | // All Keys 13 | static NSString *const OnTintColor = @"OnTintColor"; 14 | static NSString *const OnBackgroundColor = @"OnBackgroundColor"; 15 | static NSString *const OffTintColor = @"OffTintColor"; 16 | static NSString *const OffBackgroundColor = @"OffBackgroundColor"; 17 | static NSString *const TintColor = @"TintColor"; 18 | 19 | @class WZBSwitch; 20 | 21 | typedef void(^SwitchValueChangeBlock)(WZBSwitch *swith, BOOL on); 22 | 23 | @protocol WZBSwitchDelegate 24 | 25 | @optional 26 | - (void)switchValueChange:(WZBSwitch *)swith on:(BOOL)on; 27 | 28 | @end 29 | 30 | @interface WZBSwitch : UIView 31 | /** 开关开启状态的顶部滑块颜色 默认是白色 */ 32 | @property (nonatomic, strong) UIColor *onTintColor; 33 | /** 开关开启状态的底部背景颜色 默认是绿色 */ 34 | @property (nonatomic, strong) UIColor *onBackgroundColor; 35 | /** 开关关闭状态的顶部滑块颜色 默认是白色 */ 36 | @property (nonatomic, strong) UIColor *offTintColor; 37 | /** 开关关闭状态的底部背景颜色 默认是白色 */ 38 | @property (nonatomic, strong) UIColor *offBackgroundColor; 39 | /** 开关的风格颜色 边框颜色 默认是亮灰色 */ 40 | @property(nonatomic, strong) UIColor *tintColor; 41 | /** 查看开关打开状态, 默认为关闭 */ 42 | @property (nonatomic, readonly, getter=isOn) BOOL on; 43 | /** 开关状态改变回调block */ 44 | @property (nonatomic, copy) SwitchValueChangeBlock switchValueChange; 45 | /** delegate */ 46 | @property (nonatomic, weak) id delegate; 47 | 48 | - (instancetype)initWithFrame:(CGRect)frame switchValueChanged:(SwitchValueChangeBlock)switchValueChange; 49 | /** 一个方法设置所有颜色 */ 50 | - (void)setUpAllColors:(NSDictionary *(^)(UIColor **onTintColor,UIColor **onBackgroundColor, UIColor **offTintColor, UIColor **offBackgroundColor, UIColor **tintColor))allColorBlock; 51 | /** 一个方法设置所有颜色 && block回调 52 | * switchValueChange: 开关状态改变回调block 53 | */ 54 | - (void)setUpAllColors:(NSDictionary *(^)(UIColor **onTintColor,UIColor **onBackgroundColor, UIColor **offTintColor, UIColor **offBackgroundColor, UIColor **tintColor))allColorBlock switchValueChanged:(SwitchValueChangeBlock)switchValueChange; 55 | /** 设置开关状态, animated : 是否有动画 */ 56 | - (void)setOn:(BOOL)newOn animated:(BOOL)animated; 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WZBSwitch 2 | 实现了一个很简单的自定义开关控件 3 | 用法如下 4 | 5 | 将WZBSwitch.h和WZBSwitch.m拖入工程 6 | 7 | 在需要使用的地方调用 8 | ``` 9 | /** 初始化方法 10 | * switchValueChange: 开关状态改变回调block 11 | */ 12 | WZBSwitch *switchView = [[WZBSwitch alloc] initWithFrame:CGRectMake(100, 100, 50, 25) switchValueChanged:^(WZBSwitch *swith, BOOL on) { 13 | // do someing 14 | }]; 15 | [self.view addSubview:switchView]; 16 | ``` 17 | 18 | 对于开关状态的监听或者您还可以通过代理: 19 | 20 | ``` 21 | WZBSwitch *switchView = [[WZBSwitch alloc] initWithFrame:CGRectMake(100, 100, 50, 25)]; 22 | [self.view addSubview:switchView]; 23 | // delegate 24 | switchView.delegate = self; 25 | ``` 26 | 27 | 然后实现代理方法即可 28 | 29 | ``` 30 | #pragma mark - WZBSwitchDelegate 31 | - (void)switchValueChange:(WZBSwitch *)swith on:(BOOL)on { 32 | // do someing 33 | } 34 | ``` 35 | 36 | 效果如下: 37 | 38 | 39 | ![image](https://github.com/WZBbiao/WZBSwitch/blob/master/WZBSwitch.gif?raw=true) 40 | 41 | 如果您想自定义开关颜色,代码如下: 42 | 43 | // 设置所有颜色 44 | 45 | ``` 46 | [switchView setUpAllColors:^NSDictionary *(UIColor *__autoreleasing *onTintColor, UIColor *__autoreleasing *onBackgroundColor, UIColor *__autoreleasing *offTintColor, UIColor *__autoreleasing *offBackgroundColor, UIColor *__autoreleasing *tintColor) { 47 | // 可以通过这种方法设置需要设置的颜色 48 | *onTintColor = [UIColor redColor]; 49 | *onBackgroundColor = [UIColor blueColor]; 50 | *offTintColor = [UIColor greenColor]; 51 | *offBackgroundColor = [UIColor grayColor]; 52 | *tintColor = [UIColor blackColor]; 53 | return nil; 54 | }]; 55 | ``` 56 | 57 | 或者这样 58 | 59 | ``` 60 | [switchView setUpAllColors:^NSDictionary *(UIColor *__autoreleasing *onTintColor, UIColor *__autoreleasing *onBackgroundColor, UIColor *__autoreleasing *offTintColor, UIColor *__autoreleasing *offBackgroundColor, UIColor *__autoreleasing *tintColor) { 61 | // 也可以通过这种方法设置需要设置的颜色 62 | return @{OnTintColor : WZBColor(234, 67, 53), OnBackgroundColor : WZBColor(244, 161, 154), OffTintColor : WZBColor(255, 255, 255), OffBackgroundColor : WZBColor(214, 214, 214), TintColor : [UIColor colorWithRed:0.8252 green:0.8252 blue:0.8252 alpha:1.0]}; 63 | }]; 64 | ``` 65 | 66 | 您还可以加入我们的群,大家庭期待您的加入! 67 | 68 | ![image](https://raw.githubusercontent.com/WZBbiao/WZBSwitch/master/IMG_1850.JPG) 69 | -------------------------------------------------------------------------------- /WZBSwitch - demo/WZBSwitch/WZBSwitch.m: -------------------------------------------------------------------------------- 1 | // 2 | // WZBSwitch.m 3 | // 自定义开关 4 | // 5 | // Created by WZB on 16/7/27. 6 | // Copyright © 2016年 王振标. All rights reserved. 7 | // 8 | 9 | #import "WZBSwitch.h" 10 | 11 | #define WZBScreenW [UIScreen mainScreen].bounds.size.width 12 | #define WZBScreenH [UIScreen mainScreen].bounds.size.height 13 | #define WZBWhiteColor [UIColor whiteColor] 14 | #define WZBGreenColor [UIColor greenColor] 15 | #define WZBLightGrayColor [UIColor lightGrayColor] 16 | 17 | @interface WZBSwitch () 18 | 19 | @property (nonatomic, strong) UIView *topView; 20 | @property (nonatomic, strong) UIView *bottomView; 21 | 22 | @end 23 | 24 | @implementation WZBSwitch 25 | 26 | - (instancetype)initWithFrame:(CGRect)frame { 27 | return [self initWithFrame:frame switchValueChanged:nil]; 28 | } 29 | 30 | - (instancetype)initWithFrame:(CGRect)frame switchValueChanged:(SwitchValueChangeBlock)switchValueChange { 31 | self = [super initWithFrame:frame]; 32 | if (self) { 33 | if (frame.size.width == 0 || frame.size.height == 0) { 34 | frame = CGRectMake(0, 0, 100, 50); 35 | } 36 | [self setupWithFrame:frame]; 37 | if (switchValueChange) self.switchValueChange = switchValueChange; 38 | } 39 | return self; 40 | } 41 | 42 | - (instancetype)initWithCoder:(NSCoder *)coder { 43 | self = [super initWithCoder:coder]; 44 | if (self) { 45 | [self setupWithFrame:self.frame]; 46 | } 47 | return self; 48 | } 49 | 50 | - (void)setupWithFrame:(CGRect)frame { 51 | _on = NO; 52 | self.userInteractionEnabled = YES; 53 | [self setupConfigWithFrame:frame]; 54 | } 55 | 56 | - (void)setupConfigWithFrame:(CGRect)frame { 57 | CGFloat x = 0; 58 | CGFloat y = 0; 59 | CGFloat w = frame.size.width; 60 | CGFloat h = frame.size.height; 61 | self.bottomView = [[UIView alloc] initWithFrame:(CGRect) {x, y, w, h / 2}]; 62 | CGPoint center = self.bottomView.center; 63 | center.y = frame.size.height / 2; 64 | self.bottomView.center = center; 65 | [self addSubview:_bottomView]; 66 | self.bottomView.layer.cornerRadius = self.bottomView.frame.size.height / 2; 67 | 68 | self.topView = [[UIView alloc] initWithFrame:(CGRect) {x, y / 3, h, h}]; 69 | CGPoint topViewCenter = self.topView.center; 70 | topViewCenter.y = frame.size.height / 2; 71 | self.topView.center = topViewCenter; 72 | [self addSubview:_topView]; 73 | self.topView.layer.cornerRadius = self.topView.frame.size.height / 2; 74 | self.onTintColor = self.offTintColor = self.offBackgroundColor = WZBWhiteColor; 75 | self.onBackgroundColor = WZBGreenColor; 76 | self.tintColor = WZBLightGrayColor; 77 | [self setSwitchColorWithStatus:_on]; 78 | } 79 | 80 | - (void)setOn:(BOOL)newOn animated:(BOOL)animated { 81 | 82 | __block CGRect frame = self.topView.frame; 83 | CGFloat newX = newOn ? self.frame.size.width - self.topView.frame.size.width : 0; 84 | [UIView animateWithDuration:animated ? 0.2 : 0.0 animations:^{ 85 | frame.origin.x = newX; 86 | self.topView.frame = frame; 87 | [self setSwitchColorWithStatus:newOn]; 88 | } completion:^(BOOL finished) { 89 | if (finished) { 90 | // delegate 91 | if ([self.delegate respondsToSelector:@selector(switchValueChange:on:)]) { 92 | [self.delegate switchValueChange:self on:newOn]; 93 | } 94 | // block 95 | if (self.switchValueChange) { 96 | self.switchValueChange(self, newOn); 97 | } 98 | } 99 | }]; 100 | _on = newOn; 101 | } 102 | 103 | - (void)setUpAllColors:(NSDictionary *(^)(UIColor **onTintColor,UIColor **onBackgroundColor, UIColor **offTintColor, UIColor **offBackgroundColor, UIColor **tintColor))allColorBlock { 104 | [self setUpAllColors:allColorBlock switchValueChanged:self.switchValueChange]; 105 | } 106 | 107 | - (void)setUpAllColors:(NSDictionary *(^)(UIColor **onTintColor,UIColor **onBackgroundColor, UIColor **offTintColor, UIColor **offBackgroundColor, UIColor **tintColor))allColorBlock switchValueChanged:(SwitchValueChangeBlock)switchValueChange { 108 | if (switchValueChange) self.switchValueChange = switchValueChange; 109 | UIColor *onTintColor, *onBackgroundColor, *offTintColor, *offBackgroundColor, *tintColor; 110 | if (allColorBlock) { 111 | NSDictionary *allColorDict = allColorBlock(&onTintColor, &onBackgroundColor, &offTintColor, &offBackgroundColor, &tintColor); 112 | self.onTintColor = onTintColor; 113 | self.onBackgroundColor = onBackgroundColor; 114 | self.offTintColor = offTintColor; 115 | self.offBackgroundColor = offBackgroundColor; 116 | self.tintColor = tintColor; 117 | 118 | if (allColorDict) { 119 | // [self setUpSafeColor:allColorDict[OnTintColor] writedColor:self.onTintColor]; 120 | if (allColorDict[OnTintColor]) { 121 | self.onTintColor = allColorDict[OnTintColor]; 122 | } 123 | // [self setUpSafeColor:allColorDict[OnBackgroundColor] writedColor:self.onBackgroundColor]; 124 | if (allColorDict[OnBackgroundColor]) { 125 | self.onBackgroundColor = allColorDict[OnBackgroundColor]; 126 | } 127 | // [self setUpSafeColor:allColorDict[OffTintColor] writedColor:self.offTintColor]; 128 | if (allColorDict[OffTintColor]) { 129 | self.offTintColor = allColorDict[OffTintColor]; 130 | } 131 | // [self setUpSafeColor:allColorDict[OffBackgroundColor] writedColor:self.offBackgroundColor]; 132 | 133 | if (allColorDict[OffBackgroundColor]) { 134 | self.offBackgroundColor = allColorDict[OffBackgroundColor]; 135 | } 136 | // [self setUpSafeColor:allColorDict[TintColor] writedColor:self.tintColor]; 137 | if (allColorDict[TintColor]) { 138 | self.tintColor = allColorDict[TintColor]; 139 | } 140 | } 141 | } 142 | [self setSwitchColorWithStatus:_on]; 143 | } 144 | 145 | - (void)setUpSafeColor:(UIColor *)writeColor writedColor:(UIColor *)writedColor { 146 | if (writeColor) { 147 | writedColor = writeColor; 148 | } 149 | } 150 | 151 | - (void)setSwitchColorWithStatus:(BOOL)on { 152 | self.bottomView.backgroundColor = on ? _onBackgroundColor : _offBackgroundColor; 153 | self.topView.backgroundColor = on ? _onTintColor : _offTintColor; 154 | } 155 | 156 | - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { 157 | [self setOn:!_on animated:YES]; 158 | } 159 | 160 | // 开关开启状态的顶部滑块颜色 默认是灰色 161 | - (void)setOnTintColor:(UIColor *)onTintColor { 162 | _onTintColor = onTintColor; 163 | [self setSwitchColorWithStatus:_on]; 164 | } 165 | 166 | // 开关开启状态的底部背景颜色 默认是浅灰色 167 | - (void)setOnBackgroundColor:(UIColor *)onBackgroundColor { 168 | _onBackgroundColor = onBackgroundColor; 169 | [self setSwitchColorWithStatus:_on]; 170 | } 171 | 172 | // 开关关闭状态的顶部滑块颜色 默认是灰色 173 | - (void)setOffTintColor:(UIColor *)offTintColor { 174 | _offTintColor = offTintColor; 175 | [self setSwitchColorWithStatus:_on]; 176 | } 177 | 178 | // 开关关闭状态的底部背景颜色 默认是浅灰色 179 | - (void)setOffBackgroundColor:(UIColor *)offBackgroundColor { 180 | _offBackgroundColor = offBackgroundColor; 181 | [self setSwitchColorWithStatus:_on]; 182 | } 183 | 184 | // 开关的风格颜色 边框颜色 默认是无色 185 | - (void)setTintColor:(UIColor *)tintColor { 186 | _tintColor = tintColor; 187 | self.topView.layer.borderColor = self.bottomView.layer.borderColor = tintColor.CGColor; 188 | self.topView.layer.borderWidth = self.bottomView.layer.borderWidth = 0.5f; 189 | [self setSwitchColorWithStatus:_on]; 190 | } 191 | 192 | @end 193 | -------------------------------------------------------------------------------- /WZBSwitch - demo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 98BC77531DB0D3D8007E8CE5 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 98BC77521DB0D3D8007E8CE5 /* main.m */; }; 11 | 98BC77561DB0D3D8007E8CE5 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 98BC77551DB0D3D8007E8CE5 /* AppDelegate.m */; }; 12 | 98BC77591DB0D3D8007E8CE5 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 98BC77581DB0D3D8007E8CE5 /* ViewController.m */; }; 13 | 98BC775C1DB0D3D8007E8CE5 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 98BC775A1DB0D3D8007E8CE5 /* Main.storyboard */; }; 14 | 98BC775E1DB0D3D8007E8CE5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 98BC775D1DB0D3D8007E8CE5 /* Assets.xcassets */; }; 15 | 98BC77611DB0D3D8007E8CE5 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 98BC775F1DB0D3D8007E8CE5 /* LaunchScreen.storyboard */; }; 16 | 98BC776C1DB0D3D8007E8CE5 /* WZBSwitch___demoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 98BC776B1DB0D3D8007E8CE5 /* WZBSwitch___demoTests.m */; }; 17 | 98BC77771DB0D3D9007E8CE5 /* WZBSwitch___demoUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 98BC77761DB0D3D9007E8CE5 /* WZBSwitch___demoUITests.m */; }; 18 | 98BC77871DB0D408007E8CE5 /* WZBSwitch.m in Sources */ = {isa = PBXBuildFile; fileRef = 98BC77861DB0D408007E8CE5 /* WZBSwitch.m */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXContainerItemProxy section */ 22 | 98BC77681DB0D3D8007E8CE5 /* PBXContainerItemProxy */ = { 23 | isa = PBXContainerItemProxy; 24 | containerPortal = 98BC77461DB0D3D8007E8CE5 /* Project object */; 25 | proxyType = 1; 26 | remoteGlobalIDString = 98BC774D1DB0D3D8007E8CE5; 27 | remoteInfo = "WZBSwitch - demo"; 28 | }; 29 | 98BC77731DB0D3D8007E8CE5 /* PBXContainerItemProxy */ = { 30 | isa = PBXContainerItemProxy; 31 | containerPortal = 98BC77461DB0D3D8007E8CE5 /* Project object */; 32 | proxyType = 1; 33 | remoteGlobalIDString = 98BC774D1DB0D3D8007E8CE5; 34 | remoteInfo = "WZBSwitch - demo"; 35 | }; 36 | /* End PBXContainerItemProxy section */ 37 | 38 | /* Begin PBXFileReference section */ 39 | 98BC774E1DB0D3D8007E8CE5 /* WZBSwitch - demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "WZBSwitch - demo.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 40 | 98BC77521DB0D3D8007E8CE5 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 41 | 98BC77541DB0D3D8007E8CE5 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 42 | 98BC77551DB0D3D8007E8CE5 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 43 | 98BC77571DB0D3D8007E8CE5 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 44 | 98BC77581DB0D3D8007E8CE5 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 45 | 98BC775B1DB0D3D8007E8CE5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 46 | 98BC775D1DB0D3D8007E8CE5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 47 | 98BC77601DB0D3D8007E8CE5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 48 | 98BC77621DB0D3D8007E8CE5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 49 | 98BC77671DB0D3D8007E8CE5 /* WZBSwitch - demoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "WZBSwitch - demoTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 50 | 98BC776B1DB0D3D8007E8CE5 /* WZBSwitch___demoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "WZBSwitch___demoTests.m"; sourceTree = ""; }; 51 | 98BC776D1DB0D3D8007E8CE5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 52 | 98BC77721DB0D3D8007E8CE5 /* WZBSwitch - demoUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "WZBSwitch - demoUITests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 53 | 98BC77761DB0D3D9007E8CE5 /* WZBSwitch___demoUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "WZBSwitch___demoUITests.m"; sourceTree = ""; }; 54 | 98BC77781DB0D3D9007E8CE5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 55 | 98BC77851DB0D408007E8CE5 /* WZBSwitch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WZBSwitch.h; sourceTree = ""; }; 56 | 98BC77861DB0D408007E8CE5 /* WZBSwitch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WZBSwitch.m; sourceTree = ""; }; 57 | /* End PBXFileReference section */ 58 | 59 | /* Begin PBXFrameworksBuildPhase section */ 60 | 98BC774B1DB0D3D8007E8CE5 /* Frameworks */ = { 61 | isa = PBXFrameworksBuildPhase; 62 | buildActionMask = 2147483647; 63 | files = ( 64 | ); 65 | runOnlyForDeploymentPostprocessing = 0; 66 | }; 67 | 98BC77641DB0D3D8007E8CE5 /* Frameworks */ = { 68 | isa = PBXFrameworksBuildPhase; 69 | buildActionMask = 2147483647; 70 | files = ( 71 | ); 72 | runOnlyForDeploymentPostprocessing = 0; 73 | }; 74 | 98BC776F1DB0D3D8007E8CE5 /* Frameworks */ = { 75 | isa = PBXFrameworksBuildPhase; 76 | buildActionMask = 2147483647; 77 | files = ( 78 | ); 79 | runOnlyForDeploymentPostprocessing = 0; 80 | }; 81 | /* End PBXFrameworksBuildPhase section */ 82 | 83 | /* Begin PBXGroup section */ 84 | 98BC77451DB0D3D7007E8CE5 = { 85 | isa = PBXGroup; 86 | children = ( 87 | 98BC77501DB0D3D8007E8CE5 /* WZBSwitch - demo */, 88 | 98BC776A1DB0D3D8007E8CE5 /* WZBSwitch - demoTests */, 89 | 98BC77751DB0D3D9007E8CE5 /* WZBSwitch - demoUITests */, 90 | 98BC774F1DB0D3D8007E8CE5 /* Products */, 91 | ); 92 | sourceTree = ""; 93 | }; 94 | 98BC774F1DB0D3D8007E8CE5 /* Products */ = { 95 | isa = PBXGroup; 96 | children = ( 97 | 98BC774E1DB0D3D8007E8CE5 /* WZBSwitch - demo.app */, 98 | 98BC77671DB0D3D8007E8CE5 /* WZBSwitch - demoTests.xctest */, 99 | 98BC77721DB0D3D8007E8CE5 /* WZBSwitch - demoUITests.xctest */, 100 | ); 101 | name = Products; 102 | sourceTree = ""; 103 | }; 104 | 98BC77501DB0D3D8007E8CE5 /* WZBSwitch - demo */ = { 105 | isa = PBXGroup; 106 | children = ( 107 | 98BC77841DB0D3F6007E8CE5 /* WZBSwitch */, 108 | 98BC77541DB0D3D8007E8CE5 /* AppDelegate.h */, 109 | 98BC77551DB0D3D8007E8CE5 /* AppDelegate.m */, 110 | 98BC77571DB0D3D8007E8CE5 /* ViewController.h */, 111 | 98BC77581DB0D3D8007E8CE5 /* ViewController.m */, 112 | 98BC775A1DB0D3D8007E8CE5 /* Main.storyboard */, 113 | 98BC775D1DB0D3D8007E8CE5 /* Assets.xcassets */, 114 | 98BC775F1DB0D3D8007E8CE5 /* LaunchScreen.storyboard */, 115 | 98BC77621DB0D3D8007E8CE5 /* Info.plist */, 116 | 98BC77511DB0D3D8007E8CE5 /* Supporting Files */, 117 | ); 118 | path = "WZBSwitch - demo"; 119 | sourceTree = ""; 120 | }; 121 | 98BC77511DB0D3D8007E8CE5 /* Supporting Files */ = { 122 | isa = PBXGroup; 123 | children = ( 124 | 98BC77521DB0D3D8007E8CE5 /* main.m */, 125 | ); 126 | name = "Supporting Files"; 127 | sourceTree = ""; 128 | }; 129 | 98BC776A1DB0D3D8007E8CE5 /* WZBSwitch - demoTests */ = { 130 | isa = PBXGroup; 131 | children = ( 132 | 98BC776B1DB0D3D8007E8CE5 /* WZBSwitch___demoTests.m */, 133 | 98BC776D1DB0D3D8007E8CE5 /* Info.plist */, 134 | ); 135 | path = "WZBSwitch - demoTests"; 136 | sourceTree = ""; 137 | }; 138 | 98BC77751DB0D3D9007E8CE5 /* WZBSwitch - demoUITests */ = { 139 | isa = PBXGroup; 140 | children = ( 141 | 98BC77761DB0D3D9007E8CE5 /* WZBSwitch___demoUITests.m */, 142 | 98BC77781DB0D3D9007E8CE5 /* Info.plist */, 143 | ); 144 | path = "WZBSwitch - demoUITests"; 145 | sourceTree = ""; 146 | }; 147 | 98BC77841DB0D3F6007E8CE5 /* WZBSwitch */ = { 148 | isa = PBXGroup; 149 | children = ( 150 | 98BC77851DB0D408007E8CE5 /* WZBSwitch.h */, 151 | 98BC77861DB0D408007E8CE5 /* WZBSwitch.m */, 152 | ); 153 | path = WZBSwitch; 154 | sourceTree = ""; 155 | }; 156 | /* End PBXGroup section */ 157 | 158 | /* Begin PBXNativeTarget section */ 159 | 98BC774D1DB0D3D8007E8CE5 /* WZBSwitch - demo */ = { 160 | isa = PBXNativeTarget; 161 | buildConfigurationList = 98BC777B1DB0D3D9007E8CE5 /* Build configuration list for PBXNativeTarget "WZBSwitch - demo" */; 162 | buildPhases = ( 163 | 98BC774A1DB0D3D8007E8CE5 /* Sources */, 164 | 98BC774B1DB0D3D8007E8CE5 /* Frameworks */, 165 | 98BC774C1DB0D3D8007E8CE5 /* Resources */, 166 | ); 167 | buildRules = ( 168 | ); 169 | dependencies = ( 170 | ); 171 | name = "WZBSwitch - demo"; 172 | productName = "WZBSwitch - demo"; 173 | productReference = 98BC774E1DB0D3D8007E8CE5 /* WZBSwitch - demo.app */; 174 | productType = "com.apple.product-type.application"; 175 | }; 176 | 98BC77661DB0D3D8007E8CE5 /* WZBSwitch - demoTests */ = { 177 | isa = PBXNativeTarget; 178 | buildConfigurationList = 98BC777E1DB0D3D9007E8CE5 /* Build configuration list for PBXNativeTarget "WZBSwitch - demoTests" */; 179 | buildPhases = ( 180 | 98BC77631DB0D3D8007E8CE5 /* Sources */, 181 | 98BC77641DB0D3D8007E8CE5 /* Frameworks */, 182 | 98BC77651DB0D3D8007E8CE5 /* Resources */, 183 | ); 184 | buildRules = ( 185 | ); 186 | dependencies = ( 187 | 98BC77691DB0D3D8007E8CE5 /* PBXTargetDependency */, 188 | ); 189 | name = "WZBSwitch - demoTests"; 190 | productName = "WZBSwitch - demoTests"; 191 | productReference = 98BC77671DB0D3D8007E8CE5 /* WZBSwitch - demoTests.xctest */; 192 | productType = "com.apple.product-type.bundle.unit-test"; 193 | }; 194 | 98BC77711DB0D3D8007E8CE5 /* WZBSwitch - demoUITests */ = { 195 | isa = PBXNativeTarget; 196 | buildConfigurationList = 98BC77811DB0D3D9007E8CE5 /* Build configuration list for PBXNativeTarget "WZBSwitch - demoUITests" */; 197 | buildPhases = ( 198 | 98BC776E1DB0D3D8007E8CE5 /* Sources */, 199 | 98BC776F1DB0D3D8007E8CE5 /* Frameworks */, 200 | 98BC77701DB0D3D8007E8CE5 /* Resources */, 201 | ); 202 | buildRules = ( 203 | ); 204 | dependencies = ( 205 | 98BC77741DB0D3D8007E8CE5 /* PBXTargetDependency */, 206 | ); 207 | name = "WZBSwitch - demoUITests"; 208 | productName = "WZBSwitch - demoUITests"; 209 | productReference = 98BC77721DB0D3D8007E8CE5 /* WZBSwitch - demoUITests.xctest */; 210 | productType = "com.apple.product-type.bundle.ui-testing"; 211 | }; 212 | /* End PBXNativeTarget section */ 213 | 214 | /* Begin PBXProject section */ 215 | 98BC77461DB0D3D8007E8CE5 /* Project object */ = { 216 | isa = PBXProject; 217 | attributes = { 218 | LastUpgradeCheck = 0800; 219 | ORGANIZATIONNAME = normal; 220 | TargetAttributes = { 221 | 98BC774D1DB0D3D8007E8CE5 = { 222 | CreatedOnToolsVersion = 8.0; 223 | DevelopmentTeam = 8HYJW979TJ; 224 | ProvisioningStyle = Automatic; 225 | }; 226 | 98BC77661DB0D3D8007E8CE5 = { 227 | CreatedOnToolsVersion = 8.0; 228 | DevelopmentTeam = 8HYJW979TJ; 229 | ProvisioningStyle = Automatic; 230 | TestTargetID = 98BC774D1DB0D3D8007E8CE5; 231 | }; 232 | 98BC77711DB0D3D8007E8CE5 = { 233 | CreatedOnToolsVersion = 8.0; 234 | DevelopmentTeam = 8HYJW979TJ; 235 | ProvisioningStyle = Automatic; 236 | TestTargetID = 98BC774D1DB0D3D8007E8CE5; 237 | }; 238 | }; 239 | }; 240 | buildConfigurationList = 98BC77491DB0D3D8007E8CE5 /* Build configuration list for PBXProject "WZBSwitch - demo" */; 241 | compatibilityVersion = "Xcode 3.2"; 242 | developmentRegion = English; 243 | hasScannedForEncodings = 0; 244 | knownRegions = ( 245 | en, 246 | Base, 247 | ); 248 | mainGroup = 98BC77451DB0D3D7007E8CE5; 249 | productRefGroup = 98BC774F1DB0D3D8007E8CE5 /* Products */; 250 | projectDirPath = ""; 251 | projectRoot = ""; 252 | targets = ( 253 | 98BC774D1DB0D3D8007E8CE5 /* WZBSwitch - demo */, 254 | 98BC77661DB0D3D8007E8CE5 /* WZBSwitch - demoTests */, 255 | 98BC77711DB0D3D8007E8CE5 /* WZBSwitch - demoUITests */, 256 | ); 257 | }; 258 | /* End PBXProject section */ 259 | 260 | /* Begin PBXResourcesBuildPhase section */ 261 | 98BC774C1DB0D3D8007E8CE5 /* Resources */ = { 262 | isa = PBXResourcesBuildPhase; 263 | buildActionMask = 2147483647; 264 | files = ( 265 | 98BC77611DB0D3D8007E8CE5 /* LaunchScreen.storyboard in Resources */, 266 | 98BC775E1DB0D3D8007E8CE5 /* Assets.xcassets in Resources */, 267 | 98BC775C1DB0D3D8007E8CE5 /* Main.storyboard in Resources */, 268 | ); 269 | runOnlyForDeploymentPostprocessing = 0; 270 | }; 271 | 98BC77651DB0D3D8007E8CE5 /* Resources */ = { 272 | isa = PBXResourcesBuildPhase; 273 | buildActionMask = 2147483647; 274 | files = ( 275 | ); 276 | runOnlyForDeploymentPostprocessing = 0; 277 | }; 278 | 98BC77701DB0D3D8007E8CE5 /* Resources */ = { 279 | isa = PBXResourcesBuildPhase; 280 | buildActionMask = 2147483647; 281 | files = ( 282 | ); 283 | runOnlyForDeploymentPostprocessing = 0; 284 | }; 285 | /* End PBXResourcesBuildPhase section */ 286 | 287 | /* Begin PBXSourcesBuildPhase section */ 288 | 98BC774A1DB0D3D8007E8CE5 /* Sources */ = { 289 | isa = PBXSourcesBuildPhase; 290 | buildActionMask = 2147483647; 291 | files = ( 292 | 98BC77591DB0D3D8007E8CE5 /* ViewController.m in Sources */, 293 | 98BC77561DB0D3D8007E8CE5 /* AppDelegate.m in Sources */, 294 | 98BC77531DB0D3D8007E8CE5 /* main.m in Sources */, 295 | 98BC77871DB0D408007E8CE5 /* WZBSwitch.m in Sources */, 296 | ); 297 | runOnlyForDeploymentPostprocessing = 0; 298 | }; 299 | 98BC77631DB0D3D8007E8CE5 /* Sources */ = { 300 | isa = PBXSourcesBuildPhase; 301 | buildActionMask = 2147483647; 302 | files = ( 303 | 98BC776C1DB0D3D8007E8CE5 /* WZBSwitch___demoTests.m in Sources */, 304 | ); 305 | runOnlyForDeploymentPostprocessing = 0; 306 | }; 307 | 98BC776E1DB0D3D8007E8CE5 /* Sources */ = { 308 | isa = PBXSourcesBuildPhase; 309 | buildActionMask = 2147483647; 310 | files = ( 311 | 98BC77771DB0D3D9007E8CE5 /* WZBSwitch___demoUITests.m in Sources */, 312 | ); 313 | runOnlyForDeploymentPostprocessing = 0; 314 | }; 315 | /* End PBXSourcesBuildPhase section */ 316 | 317 | /* Begin PBXTargetDependency section */ 318 | 98BC77691DB0D3D8007E8CE5 /* PBXTargetDependency */ = { 319 | isa = PBXTargetDependency; 320 | target = 98BC774D1DB0D3D8007E8CE5 /* WZBSwitch - demo */; 321 | targetProxy = 98BC77681DB0D3D8007E8CE5 /* PBXContainerItemProxy */; 322 | }; 323 | 98BC77741DB0D3D8007E8CE5 /* PBXTargetDependency */ = { 324 | isa = PBXTargetDependency; 325 | target = 98BC774D1DB0D3D8007E8CE5 /* WZBSwitch - demo */; 326 | targetProxy = 98BC77731DB0D3D8007E8CE5 /* PBXContainerItemProxy */; 327 | }; 328 | /* End PBXTargetDependency section */ 329 | 330 | /* Begin PBXVariantGroup section */ 331 | 98BC775A1DB0D3D8007E8CE5 /* Main.storyboard */ = { 332 | isa = PBXVariantGroup; 333 | children = ( 334 | 98BC775B1DB0D3D8007E8CE5 /* Base */, 335 | ); 336 | name = Main.storyboard; 337 | sourceTree = ""; 338 | }; 339 | 98BC775F1DB0D3D8007E8CE5 /* LaunchScreen.storyboard */ = { 340 | isa = PBXVariantGroup; 341 | children = ( 342 | 98BC77601DB0D3D8007E8CE5 /* Base */, 343 | ); 344 | name = LaunchScreen.storyboard; 345 | sourceTree = ""; 346 | }; 347 | /* End PBXVariantGroup section */ 348 | 349 | /* Begin XCBuildConfiguration section */ 350 | 98BC77791DB0D3D9007E8CE5 /* Debug */ = { 351 | isa = XCBuildConfiguration; 352 | buildSettings = { 353 | ALWAYS_SEARCH_USER_PATHS = NO; 354 | CLANG_ANALYZER_NONNULL = YES; 355 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 356 | CLANG_CXX_LIBRARY = "libc++"; 357 | CLANG_ENABLE_MODULES = YES; 358 | CLANG_ENABLE_OBJC_ARC = YES; 359 | CLANG_WARN_BOOL_CONVERSION = YES; 360 | CLANG_WARN_CONSTANT_CONVERSION = YES; 361 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 362 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 363 | CLANG_WARN_EMPTY_BODY = YES; 364 | CLANG_WARN_ENUM_CONVERSION = YES; 365 | CLANG_WARN_INFINITE_RECURSION = YES; 366 | CLANG_WARN_INT_CONVERSION = YES; 367 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 368 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 369 | CLANG_WARN_UNREACHABLE_CODE = YES; 370 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 371 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 372 | COPY_PHASE_STRIP = NO; 373 | DEBUG_INFORMATION_FORMAT = dwarf; 374 | ENABLE_STRICT_OBJC_MSGSEND = YES; 375 | ENABLE_TESTABILITY = YES; 376 | GCC_C_LANGUAGE_STANDARD = gnu99; 377 | GCC_DYNAMIC_NO_PIC = NO; 378 | GCC_NO_COMMON_BLOCKS = YES; 379 | GCC_OPTIMIZATION_LEVEL = 0; 380 | GCC_PREPROCESSOR_DEFINITIONS = ( 381 | "DEBUG=1", 382 | "$(inherited)", 383 | ); 384 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 385 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 386 | GCC_WARN_UNDECLARED_SELECTOR = YES; 387 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 388 | GCC_WARN_UNUSED_FUNCTION = YES; 389 | GCC_WARN_UNUSED_VARIABLE = YES; 390 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 391 | MTL_ENABLE_DEBUG_INFO = YES; 392 | ONLY_ACTIVE_ARCH = YES; 393 | SDKROOT = iphoneos; 394 | }; 395 | name = Debug; 396 | }; 397 | 98BC777A1DB0D3D9007E8CE5 /* Release */ = { 398 | isa = XCBuildConfiguration; 399 | buildSettings = { 400 | ALWAYS_SEARCH_USER_PATHS = NO; 401 | CLANG_ANALYZER_NONNULL = YES; 402 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 403 | CLANG_CXX_LIBRARY = "libc++"; 404 | CLANG_ENABLE_MODULES = YES; 405 | CLANG_ENABLE_OBJC_ARC = YES; 406 | CLANG_WARN_BOOL_CONVERSION = YES; 407 | CLANG_WARN_CONSTANT_CONVERSION = YES; 408 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 409 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 410 | CLANG_WARN_EMPTY_BODY = YES; 411 | CLANG_WARN_ENUM_CONVERSION = YES; 412 | CLANG_WARN_INFINITE_RECURSION = YES; 413 | CLANG_WARN_INT_CONVERSION = YES; 414 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 415 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 416 | CLANG_WARN_UNREACHABLE_CODE = YES; 417 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 418 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 419 | COPY_PHASE_STRIP = NO; 420 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 421 | ENABLE_NS_ASSERTIONS = NO; 422 | ENABLE_STRICT_OBJC_MSGSEND = YES; 423 | GCC_C_LANGUAGE_STANDARD = gnu99; 424 | GCC_NO_COMMON_BLOCKS = YES; 425 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 426 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 427 | GCC_WARN_UNDECLARED_SELECTOR = YES; 428 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 429 | GCC_WARN_UNUSED_FUNCTION = YES; 430 | GCC_WARN_UNUSED_VARIABLE = YES; 431 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 432 | MTL_ENABLE_DEBUG_INFO = NO; 433 | SDKROOT = iphoneos; 434 | VALIDATE_PRODUCT = YES; 435 | }; 436 | name = Release; 437 | }; 438 | 98BC777C1DB0D3D9007E8CE5 /* Debug */ = { 439 | isa = XCBuildConfiguration; 440 | buildSettings = { 441 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 442 | DEVELOPMENT_TEAM = 8HYJW979TJ; 443 | INFOPLIST_FILE = "WZBSwitch - demo/Info.plist"; 444 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 445 | PRODUCT_BUNDLE_IDENTIFIER = "WZB.WZBSwitch---demo"; 446 | PRODUCT_NAME = "$(TARGET_NAME)"; 447 | }; 448 | name = Debug; 449 | }; 450 | 98BC777D1DB0D3D9007E8CE5 /* Release */ = { 451 | isa = XCBuildConfiguration; 452 | buildSettings = { 453 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 454 | DEVELOPMENT_TEAM = 8HYJW979TJ; 455 | INFOPLIST_FILE = "WZBSwitch - demo/Info.plist"; 456 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 457 | PRODUCT_BUNDLE_IDENTIFIER = "WZB.WZBSwitch---demo"; 458 | PRODUCT_NAME = "$(TARGET_NAME)"; 459 | }; 460 | name = Release; 461 | }; 462 | 98BC777F1DB0D3D9007E8CE5 /* Debug */ = { 463 | isa = XCBuildConfiguration; 464 | buildSettings = { 465 | BUNDLE_LOADER = "$(TEST_HOST)"; 466 | DEVELOPMENT_TEAM = 8HYJW979TJ; 467 | INFOPLIST_FILE = "WZBSwitch - demoTests/Info.plist"; 468 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 469 | PRODUCT_BUNDLE_IDENTIFIER = "WZB.WZBSwitch---demoTests"; 470 | PRODUCT_NAME = "$(TARGET_NAME)"; 471 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WZBSwitch - demo.app/WZBSwitch - demo"; 472 | }; 473 | name = Debug; 474 | }; 475 | 98BC77801DB0D3D9007E8CE5 /* Release */ = { 476 | isa = XCBuildConfiguration; 477 | buildSettings = { 478 | BUNDLE_LOADER = "$(TEST_HOST)"; 479 | DEVELOPMENT_TEAM = 8HYJW979TJ; 480 | INFOPLIST_FILE = "WZBSwitch - demoTests/Info.plist"; 481 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 482 | PRODUCT_BUNDLE_IDENTIFIER = "WZB.WZBSwitch---demoTests"; 483 | PRODUCT_NAME = "$(TARGET_NAME)"; 484 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WZBSwitch - demo.app/WZBSwitch - demo"; 485 | }; 486 | name = Release; 487 | }; 488 | 98BC77821DB0D3D9007E8CE5 /* Debug */ = { 489 | isa = XCBuildConfiguration; 490 | buildSettings = { 491 | DEVELOPMENT_TEAM = 8HYJW979TJ; 492 | INFOPLIST_FILE = "WZBSwitch - demoUITests/Info.plist"; 493 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 494 | PRODUCT_BUNDLE_IDENTIFIER = "WZB.WZBSwitch---demoUITests"; 495 | PRODUCT_NAME = "$(TARGET_NAME)"; 496 | TEST_TARGET_NAME = "WZBSwitch - demo"; 497 | }; 498 | name = Debug; 499 | }; 500 | 98BC77831DB0D3D9007E8CE5 /* Release */ = { 501 | isa = XCBuildConfiguration; 502 | buildSettings = { 503 | DEVELOPMENT_TEAM = 8HYJW979TJ; 504 | INFOPLIST_FILE = "WZBSwitch - demoUITests/Info.plist"; 505 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 506 | PRODUCT_BUNDLE_IDENTIFIER = "WZB.WZBSwitch---demoUITests"; 507 | PRODUCT_NAME = "$(TARGET_NAME)"; 508 | TEST_TARGET_NAME = "WZBSwitch - demo"; 509 | }; 510 | name = Release; 511 | }; 512 | /* End XCBuildConfiguration section */ 513 | 514 | /* Begin XCConfigurationList section */ 515 | 98BC77491DB0D3D8007E8CE5 /* Build configuration list for PBXProject "WZBSwitch - demo" */ = { 516 | isa = XCConfigurationList; 517 | buildConfigurations = ( 518 | 98BC77791DB0D3D9007E8CE5 /* Debug */, 519 | 98BC777A1DB0D3D9007E8CE5 /* Release */, 520 | ); 521 | defaultConfigurationIsVisible = 0; 522 | defaultConfigurationName = Release; 523 | }; 524 | 98BC777B1DB0D3D9007E8CE5 /* Build configuration list for PBXNativeTarget "WZBSwitch - demo" */ = { 525 | isa = XCConfigurationList; 526 | buildConfigurations = ( 527 | 98BC777C1DB0D3D9007E8CE5 /* Debug */, 528 | 98BC777D1DB0D3D9007E8CE5 /* Release */, 529 | ); 530 | defaultConfigurationIsVisible = 0; 531 | }; 532 | 98BC777E1DB0D3D9007E8CE5 /* Build configuration list for PBXNativeTarget "WZBSwitch - demoTests" */ = { 533 | isa = XCConfigurationList; 534 | buildConfigurations = ( 535 | 98BC777F1DB0D3D9007E8CE5 /* Debug */, 536 | 98BC77801DB0D3D9007E8CE5 /* Release */, 537 | ); 538 | defaultConfigurationIsVisible = 0; 539 | }; 540 | 98BC77811DB0D3D9007E8CE5 /* Build configuration list for PBXNativeTarget "WZBSwitch - demoUITests" */ = { 541 | isa = XCConfigurationList; 542 | buildConfigurations = ( 543 | 98BC77821DB0D3D9007E8CE5 /* Debug */, 544 | 98BC77831DB0D3D9007E8CE5 /* Release */, 545 | ); 546 | defaultConfigurationIsVisible = 0; 547 | }; 548 | /* End XCConfigurationList section */ 549 | }; 550 | rootObject = 98BC77461DB0D3D8007E8CE5 /* Project object */; 551 | } 552 | --------------------------------------------------------------------------------