├── .gitignore ├── .travis.yml ├── Example ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── Icon-40.png │ │ ├── Icon-40@2x.png │ │ ├── Icon-40@3x.png │ │ ├── Icon-60@2x.png │ │ ├── Icon-60@3x.png │ │ ├── Icon-72.png │ │ ├── Icon-72@2x.png │ │ ├── Icon-76.png │ │ ├── Icon-76@2x.png │ │ ├── Icon-83.5@2x.png │ │ ├── Icon-Small-50.png │ │ ├── Icon-Small-50@2x.png │ │ ├── Icon-Small.png │ │ ├── Icon-Small@2x.png │ │ ├── Icon-Small@3x.png │ │ ├── Icon.png │ │ └── Icon@2x.png │ ├── Brand Assets.launchimage │ │ └── Contents.json │ └── Contents.json ├── Base.lproj │ └── LaunchScreen.storyboard ├── Gifs │ ├── NinaSelectionViewAbove.gif │ ├── NinaSelectionViewBelow.gif │ ├── NinaSelectionViewDrag.gif │ ├── NinaSelectionViewHorizontal.gif │ ├── NinaSelectionViewLeft.gif │ ├── NinaSelectionViewRight.gif │ ├── NinaSelectionViewScroll.gif │ ├── NinaSelectionViewVertical.gif │ └── Sliceheader2.png ├── Info.plist ├── ViewController.h ├── ViewController.m └── main.m ├── LICENSE ├── NinaSelectionView.podspec ├── NinaSelectionView.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── RamWire.xcuserdatad │ │ └── UserInterfaceState.xcuserstate ├── xcshareddata │ └── xcschemes │ │ └── NinaSelectionView.xcscheme └── xcuserdata │ ├── RamWire.xcuserdatad │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ │ ├── NinaSelectionView.xcscheme │ │ └── xcschememanagement.plist │ └── renrun.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ └── xcschememanagement.plist ├── NinaSelectionView ├── NinaSelectionView.h ├── NinaSelectionView.m └── UIParameter.h ├── README.md └── README_CN.md /.gitignore: -------------------------------------------------------------------------------- 1 | UserInterfaceState.xcuserstate 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | osx_image: xcode7 3 | xcode_project: NinaSelectionView.xcodeproj 4 | xcode_scheme: NinaSelectionView 5 | 6 | script: 7 | - xctool -project NinaSelectionView.xcodeproj -scheme NinaSelectionView -configuration Debug CODE_SIGN_IDENTITY="" -sdk iphonesimulator test -------------------------------------------------------------------------------- /Example/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // NinaSelectionView 4 | // 5 | // Created by RamWire on 16/7/20. 6 | // Copyright © 2016年 RamWire. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /Example/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // NinaSelectionView 4 | // 5 | // Created by RamWire on 16/7/20. 6 | // Copyright © 2016年 RamWire. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "ViewController.h" 11 | 12 | @interface AppDelegate () 13 | 14 | @end 15 | 16 | @implementation AppDelegate 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | UIWindow *window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 20 | window.backgroundColor = [UIColor whiteColor]; 21 | self.window = window; 22 | [self.window makeKeyAndVisible]; 23 | ViewController *viewC = [[ViewController alloc] init]; 24 | UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewC]; 25 | self.window.rootViewController = navController; 26 | return YES; 27 | } 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Example/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "29x29", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-Small.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "29x29", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-Small@2x.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-Small@3x.png", 19 | "scale" : "3x" 20 | }, 21 | { 22 | "size" : "40x40", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-40@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "40x40", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-40@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "57x57", 35 | "idiom" : "iphone", 36 | "filename" : "Icon.png", 37 | "scale" : "1x" 38 | }, 39 | { 40 | "size" : "57x57", 41 | "idiom" : "iphone", 42 | "filename" : "Icon@2x.png", 43 | "scale" : "2x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "29x29", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-Small.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "29x29", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-Small@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "40x40", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-40.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "40x40", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-40@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "50x50", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-Small-50.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "50x50", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-Small-50@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "72x72", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-72.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "72x72", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-72@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "76x76", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-76.png", 109 | "scale" : "1x" 110 | }, 111 | { 112 | "size" : "76x76", 113 | "idiom" : "ipad", 114 | "filename" : "Icon-76@2x.png", 115 | "scale" : "2x" 116 | }, 117 | { 118 | "size" : "83.5x83.5", 119 | "idiom" : "ipad", 120 | "filename" : "Icon-83.5@2x.png", 121 | "scale" : "2x" 122 | } 123 | ], 124 | "info" : { 125 | "version" : 1, 126 | "author" : "xcode" 127 | } 128 | } -------------------------------------------------------------------------------- /Example/Assets.xcassets/AppIcon.appiconset/Icon-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RamWire/NinaSelectionView/fee20bcf2c1f6c8dbdbf1dd09c414f4f5fb20200/Example/Assets.xcassets/AppIcon.appiconset/Icon-40.png -------------------------------------------------------------------------------- /Example/Assets.xcassets/AppIcon.appiconset/Icon-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RamWire/NinaSelectionView/fee20bcf2c1f6c8dbdbf1dd09c414f4f5fb20200/Example/Assets.xcassets/AppIcon.appiconset/Icon-40@2x.png -------------------------------------------------------------------------------- /Example/Assets.xcassets/AppIcon.appiconset/Icon-40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RamWire/NinaSelectionView/fee20bcf2c1f6c8dbdbf1dd09c414f4f5fb20200/Example/Assets.xcassets/AppIcon.appiconset/Icon-40@3x.png -------------------------------------------------------------------------------- /Example/Assets.xcassets/AppIcon.appiconset/Icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RamWire/NinaSelectionView/fee20bcf2c1f6c8dbdbf1dd09c414f4f5fb20200/Example/Assets.xcassets/AppIcon.appiconset/Icon-60@2x.png -------------------------------------------------------------------------------- /Example/Assets.xcassets/AppIcon.appiconset/Icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RamWire/NinaSelectionView/fee20bcf2c1f6c8dbdbf1dd09c414f4f5fb20200/Example/Assets.xcassets/AppIcon.appiconset/Icon-60@3x.png -------------------------------------------------------------------------------- /Example/Assets.xcassets/AppIcon.appiconset/Icon-72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RamWire/NinaSelectionView/fee20bcf2c1f6c8dbdbf1dd09c414f4f5fb20200/Example/Assets.xcassets/AppIcon.appiconset/Icon-72.png -------------------------------------------------------------------------------- /Example/Assets.xcassets/AppIcon.appiconset/Icon-72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RamWire/NinaSelectionView/fee20bcf2c1f6c8dbdbf1dd09c414f4f5fb20200/Example/Assets.xcassets/AppIcon.appiconset/Icon-72@2x.png -------------------------------------------------------------------------------- /Example/Assets.xcassets/AppIcon.appiconset/Icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RamWire/NinaSelectionView/fee20bcf2c1f6c8dbdbf1dd09c414f4f5fb20200/Example/Assets.xcassets/AppIcon.appiconset/Icon-76.png -------------------------------------------------------------------------------- /Example/Assets.xcassets/AppIcon.appiconset/Icon-76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RamWire/NinaSelectionView/fee20bcf2c1f6c8dbdbf1dd09c414f4f5fb20200/Example/Assets.xcassets/AppIcon.appiconset/Icon-76@2x.png -------------------------------------------------------------------------------- /Example/Assets.xcassets/AppIcon.appiconset/Icon-83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RamWire/NinaSelectionView/fee20bcf2c1f6c8dbdbf1dd09c414f4f5fb20200/Example/Assets.xcassets/AppIcon.appiconset/Icon-83.5@2x.png -------------------------------------------------------------------------------- /Example/Assets.xcassets/AppIcon.appiconset/Icon-Small-50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RamWire/NinaSelectionView/fee20bcf2c1f6c8dbdbf1dd09c414f4f5fb20200/Example/Assets.xcassets/AppIcon.appiconset/Icon-Small-50.png -------------------------------------------------------------------------------- /Example/Assets.xcassets/AppIcon.appiconset/Icon-Small-50@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RamWire/NinaSelectionView/fee20bcf2c1f6c8dbdbf1dd09c414f4f5fb20200/Example/Assets.xcassets/AppIcon.appiconset/Icon-Small-50@2x.png -------------------------------------------------------------------------------- /Example/Assets.xcassets/AppIcon.appiconset/Icon-Small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RamWire/NinaSelectionView/fee20bcf2c1f6c8dbdbf1dd09c414f4f5fb20200/Example/Assets.xcassets/AppIcon.appiconset/Icon-Small.png -------------------------------------------------------------------------------- /Example/Assets.xcassets/AppIcon.appiconset/Icon-Small@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RamWire/NinaSelectionView/fee20bcf2c1f6c8dbdbf1dd09c414f4f5fb20200/Example/Assets.xcassets/AppIcon.appiconset/Icon-Small@2x.png -------------------------------------------------------------------------------- /Example/Assets.xcassets/AppIcon.appiconset/Icon-Small@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RamWire/NinaSelectionView/fee20bcf2c1f6c8dbdbf1dd09c414f4f5fb20200/Example/Assets.xcassets/AppIcon.appiconset/Icon-Small@3x.png -------------------------------------------------------------------------------- /Example/Assets.xcassets/AppIcon.appiconset/Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RamWire/NinaSelectionView/fee20bcf2c1f6c8dbdbf1dd09c414f4f5fb20200/Example/Assets.xcassets/AppIcon.appiconset/Icon.png -------------------------------------------------------------------------------- /Example/Assets.xcassets/AppIcon.appiconset/Icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RamWire/NinaSelectionView/fee20bcf2c1f6c8dbdbf1dd09c414f4f5fb20200/Example/Assets.xcassets/AppIcon.appiconset/Icon@2x.png -------------------------------------------------------------------------------- /Example/Assets.xcassets/Brand Assets.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "ipad", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "1x" 9 | }, 10 | { 11 | "orientation" : "landscape", 12 | "idiom" : "ipad", 13 | "extent" : "full-screen", 14 | "minimum-system-version" : "7.0", 15 | "scale" : "1x" 16 | }, 17 | { 18 | "orientation" : "portrait", 19 | "idiom" : "ipad", 20 | "extent" : "full-screen", 21 | "minimum-system-version" : "7.0", 22 | "scale" : "2x" 23 | }, 24 | { 25 | "orientation" : "landscape", 26 | "idiom" : "ipad", 27 | "extent" : "full-screen", 28 | "minimum-system-version" : "7.0", 29 | "scale" : "2x" 30 | } 31 | ], 32 | "info" : { 33 | "version" : 1, 34 | "author" : "xcode" 35 | } 36 | } -------------------------------------------------------------------------------- /Example/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Example/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 26 | 32 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /Example/Gifs/NinaSelectionViewAbove.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RamWire/NinaSelectionView/fee20bcf2c1f6c8dbdbf1dd09c414f4f5fb20200/Example/Gifs/NinaSelectionViewAbove.gif -------------------------------------------------------------------------------- /Example/Gifs/NinaSelectionViewBelow.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RamWire/NinaSelectionView/fee20bcf2c1f6c8dbdbf1dd09c414f4f5fb20200/Example/Gifs/NinaSelectionViewBelow.gif -------------------------------------------------------------------------------- /Example/Gifs/NinaSelectionViewDrag.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RamWire/NinaSelectionView/fee20bcf2c1f6c8dbdbf1dd09c414f4f5fb20200/Example/Gifs/NinaSelectionViewDrag.gif -------------------------------------------------------------------------------- /Example/Gifs/NinaSelectionViewHorizontal.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RamWire/NinaSelectionView/fee20bcf2c1f6c8dbdbf1dd09c414f4f5fb20200/Example/Gifs/NinaSelectionViewHorizontal.gif -------------------------------------------------------------------------------- /Example/Gifs/NinaSelectionViewLeft.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RamWire/NinaSelectionView/fee20bcf2c1f6c8dbdbf1dd09c414f4f5fb20200/Example/Gifs/NinaSelectionViewLeft.gif -------------------------------------------------------------------------------- /Example/Gifs/NinaSelectionViewRight.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RamWire/NinaSelectionView/fee20bcf2c1f6c8dbdbf1dd09c414f4f5fb20200/Example/Gifs/NinaSelectionViewRight.gif -------------------------------------------------------------------------------- /Example/Gifs/NinaSelectionViewScroll.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RamWire/NinaSelectionView/fee20bcf2c1f6c8dbdbf1dd09c414f4f5fb20200/Example/Gifs/NinaSelectionViewScroll.gif -------------------------------------------------------------------------------- /Example/Gifs/NinaSelectionViewVertical.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RamWire/NinaSelectionView/fee20bcf2c1f6c8dbdbf1dd09c414f4f5fb20200/Example/Gifs/NinaSelectionViewVertical.gif -------------------------------------------------------------------------------- /Example/Gifs/Sliceheader2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RamWire/NinaSelectionView/fee20bcf2c1f6c8dbdbf1dd09c414f4f5fb20200/Example/Gifs/Sliceheader2.png -------------------------------------------------------------------------------- /Example/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 | 0.1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /Example/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // NinaSelectionView 4 | // 5 | // Created by RamWire on 16/7/20. 6 | // Copyright © 2016年 RamWire. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | @end 14 | 15 | -------------------------------------------------------------------------------- /Example/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // NinaSelectionView 4 | // 5 | // Created by RamWire on 16/7/20. 6 | // Copyright © 2016年 RamWire. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "UIParameter.h" 11 | #import "NinaSelectionView.h" 12 | 13 | @interface ViewController () 14 | @property (nonatomic, strong) NinaSelectionView *ninaSelectionView; 15 | @property (nonatomic, strong) UITableView *myTableView; 16 | @end 17 | 18 | @implementation ViewController { 19 | NSString *changeStr; 20 | } 21 | 22 | - (void)viewDidLoad { 23 | [super viewDidLoad]; 24 | self.view.backgroundColor = [UIColor whiteColor]; 25 | self.title = @"Hello,Nina"; 26 | UIBarButtonItem *rightBtn = [[UIBarButtonItem alloc] initWithTitle:@"Tap" style:UIBarButtonItemStylePlain target:self action:@selector(popAction)]; 27 | self.navigationItem.rightBarButtonItem = rightBtn; 28 | self.navigationController.navigationBar.translucent = NO; 29 | self.view.backgroundColor = [UIColor whiteColor]; 30 | [self.view addSubview:self.ninaSelectionView]; 31 | [self.view addSubview:self.myTableView]; 32 | } 33 | 34 | #pragma mark - LazyLoad 35 | - (NinaSelectionView *)ninaSelectionView { 36 | if (!_ninaSelectionView) { 37 | _ninaSelectionView = [[NinaSelectionView alloc] initWithTitles:[self titlesArray] PopDirection:NinaPopFromBelowToTop]; 38 | _ninaSelectionView.ninaSelectionDelegate = self; 39 | _ninaSelectionView.defaultSelected = 1; 40 | _ninaSelectionView.shadowEffect = YES; 41 | _ninaSelectionView.shadowAlpha = 0.5; 42 | } 43 | return _ninaSelectionView; 44 | } 45 | 46 | #pragma mark - RightBarButtonItemAction 47 | - (void)popAction { 48 | [self.ninaSelectionView showOrDismissNinaViewWithDuration:0.5 usingNinaSpringWithDamping:0.8 initialNinaSpringVelocity:0.3]; 49 | // [self.ninaSelectionView showOrDismissNinaViewWithDuration:0.3]; 50 | } 51 | 52 | #pragma mark - NinaSelectionDelegate 53 | - (void)selectNinaAction:(UIButton *)button { 54 | NSLog(@"Choose %li button",(long)button.tag); 55 | changeStr = button.titleLabel.text; 56 | [self.ninaSelectionView showOrDismissNinaViewWithDuration:0.3]; 57 | [self.myTableView reloadData]; 58 | } 59 | 60 | #pragma mark - TitlesArray 61 | - (NSArray *)titlesArray { 62 | return @[ 63 | @"Curry", 64 | @"Thompson", 65 | @"Green", 66 | @"Iguodala", 67 | @"Durant", 68 | @"Curry", 69 | @"Thompson", 70 | @"Green", 71 | @"Iguodala", 72 | @"Durant", 73 | @"Green", 74 | @"Iguodala", 75 | @"Durant", 76 | @"Curry", 77 | @"Thompson", 78 | @"Green", 79 | @"Iguodala", 80 | @"Durant", 81 | ]; 82 | } 83 | 84 | #pragma mark - myTableView 85 | - (UITableView *)myTableView { 86 | if (!_myTableView) { 87 | _myTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, FUll_VIEW_WIDTH, FUll_CONTENT_HEIGHT_WITHOUT_TAB) style:UITableViewStylePlain]; 88 | _myTableView.delegate = self; 89 | _myTableView.dataSource = self; 90 | } 91 | return _myTableView; 92 | } 93 | 94 | #pragma mark - UITableViewDelegate 95 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 96 | return 20; 97 | } 98 | 99 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 100 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; 101 | if (cell == nil) { 102 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"]; 103 | } 104 | if (changeStr.length == 0) { 105 | cell.textLabel.text = @"NinaSelectionView"; 106 | }else { 107 | cell.textLabel.text = changeStr; 108 | } 109 | return cell; 110 | } 111 | 112 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 113 | [tableView deselectRowAtIndexPath:indexPath animated:YES]; 114 | } 115 | 116 | @end 117 | -------------------------------------------------------------------------------- /Example/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // NinaSelectionView 4 | // 5 | // Created by RamWire on 16/7/20. 6 | // Copyright © 2016年 RamWire. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 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 | -------------------------------------------------------------------------------- /NinaSelectionView.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'NinaSelectionView' 3 | s.version = '0.1.0' 4 | s.license = 'MIT' 5 | s.platform = :ios, '7.0' 6 | s.summary = 'A dramatic way to select your buttons by NinaSelectionView.' 7 | s.homepage = 'https://github.com/RamWire/NinaSelectionView' 8 | s.author = { 'RamWire' => 'RamWire' } 9 | s.source = { :git => 'https://github.com/RamWire/NinaSelectionView.git', :tag => s.version.to_s } 10 | s.source_files = 'NinaSelectionView/**/*.{h,m}' 11 | s.framework = 'UIKit' 12 | s.requires_arc = true 13 | end -------------------------------------------------------------------------------- /NinaSelectionView.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 7634169F1D3F151200EA57FE /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 763416951D3F151200EA57FE /* AppDelegate.m */; }; 11 | 763416A01D3F151200EA57FE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 763416961D3F151200EA57FE /* Assets.xcassets */; }; 12 | 763416A11D3F151200EA57FE /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 763416971D3F151200EA57FE /* LaunchScreen.storyboard */; }; 13 | 763416A41D3F151200EA57FE /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 7634169C1D3F151200EA57FE /* main.m */; }; 14 | 763416A51D3F151200EA57FE /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7634169E1D3F151200EA57FE /* ViewController.m */; }; 15 | 763416AC1D3F1BE100EA57FE /* NinaSelectionView.m in Sources */ = {isa = PBXBuildFile; fileRef = 763416AB1D3F1BE100EA57FE /* NinaSelectionView.m */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXFileReference section */ 19 | 763416781D3F13E700EA57FE /* NinaSelectionView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NinaSelectionView.app; sourceTree = BUILT_PRODUCTS_DIR; }; 20 | 763416941D3F151200EA57FE /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 21 | 763416951D3F151200EA57FE /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 22 | 763416961D3F151200EA57FE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 23 | 763416981D3F151200EA57FE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 24 | 7634169B1D3F151200EA57FE /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 25 | 7634169C1D3F151200EA57FE /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 26 | 7634169D1D3F151200EA57FE /* ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 27 | 7634169E1D3F151200EA57FE /* ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 28 | 763416A91D3F194600EA57FE /* UIParameter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIParameter.h; sourceTree = ""; }; 29 | 763416AA1D3F1BE100EA57FE /* NinaSelectionView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NinaSelectionView.h; sourceTree = ""; }; 30 | 763416AB1D3F1BE100EA57FE /* NinaSelectionView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NinaSelectionView.m; sourceTree = ""; }; 31 | /* End PBXFileReference section */ 32 | 33 | /* Begin PBXFrameworksBuildPhase section */ 34 | 763416751D3F13E700EA57FE /* Frameworks */ = { 35 | isa = PBXFrameworksBuildPhase; 36 | buildActionMask = 2147483647; 37 | files = ( 38 | ); 39 | runOnlyForDeploymentPostprocessing = 0; 40 | }; 41 | /* End PBXFrameworksBuildPhase section */ 42 | 43 | /* Begin PBXGroup section */ 44 | 7634166F1D3F13E700EA57FE = { 45 | isa = PBXGroup; 46 | children = ( 47 | 763416931D3F151200EA57FE /* Example */, 48 | 763416921D3F150B00EA57FE /* NinaSelectionView */, 49 | 763416791D3F13E700EA57FE /* Products */, 50 | ); 51 | sourceTree = ""; 52 | }; 53 | 763416791D3F13E700EA57FE /* Products */ = { 54 | isa = PBXGroup; 55 | children = ( 56 | 763416781D3F13E700EA57FE /* NinaSelectionView.app */, 57 | ); 58 | name = Products; 59 | sourceTree = ""; 60 | }; 61 | 763416921D3F150B00EA57FE /* NinaSelectionView */ = { 62 | isa = PBXGroup; 63 | children = ( 64 | 763416AA1D3F1BE100EA57FE /* NinaSelectionView.h */, 65 | 763416AB1D3F1BE100EA57FE /* NinaSelectionView.m */, 66 | 763416A91D3F194600EA57FE /* UIParameter.h */, 67 | ); 68 | path = NinaSelectionView; 69 | sourceTree = ""; 70 | }; 71 | 763416931D3F151200EA57FE /* Example */ = { 72 | isa = PBXGroup; 73 | children = ( 74 | 763416941D3F151200EA57FE /* AppDelegate.h */, 75 | 763416951D3F151200EA57FE /* AppDelegate.m */, 76 | 7634169D1D3F151200EA57FE /* ViewController.h */, 77 | 7634169E1D3F151200EA57FE /* ViewController.m */, 78 | 763416961D3F151200EA57FE /* Assets.xcassets */, 79 | 763416971D3F151200EA57FE /* LaunchScreen.storyboard */, 80 | 7634169B1D3F151200EA57FE /* Info.plist */, 81 | 7634169C1D3F151200EA57FE /* main.m */, 82 | ); 83 | path = Example; 84 | sourceTree = ""; 85 | }; 86 | /* End PBXGroup section */ 87 | 88 | /* Begin PBXNativeTarget section */ 89 | 763416771D3F13E700EA57FE /* NinaSelectionView */ = { 90 | isa = PBXNativeTarget; 91 | buildConfigurationList = 7634168F1D3F13E700EA57FE /* Build configuration list for PBXNativeTarget "NinaSelectionView" */; 92 | buildPhases = ( 93 | 763416741D3F13E700EA57FE /* Sources */, 94 | 763416751D3F13E700EA57FE /* Frameworks */, 95 | 763416761D3F13E700EA57FE /* Resources */, 96 | ); 97 | buildRules = ( 98 | ); 99 | dependencies = ( 100 | ); 101 | name = NinaSelectionView; 102 | productName = NinaSelectionView; 103 | productReference = 763416781D3F13E700EA57FE /* NinaSelectionView.app */; 104 | productType = "com.apple.product-type.application"; 105 | }; 106 | /* End PBXNativeTarget section */ 107 | 108 | /* Begin PBXProject section */ 109 | 763416701D3F13E700EA57FE /* Project object */ = { 110 | isa = PBXProject; 111 | attributes = { 112 | LastUpgradeCheck = 0730; 113 | ORGANIZATIONNAME = RamWire; 114 | TargetAttributes = { 115 | 763416771D3F13E700EA57FE = { 116 | CreatedOnToolsVersion = 7.3.1; 117 | }; 118 | }; 119 | }; 120 | buildConfigurationList = 763416731D3F13E700EA57FE /* Build configuration list for PBXProject "NinaSelectionView" */; 121 | compatibilityVersion = "Xcode 3.2"; 122 | developmentRegion = English; 123 | hasScannedForEncodings = 0; 124 | knownRegions = ( 125 | en, 126 | Base, 127 | ); 128 | mainGroup = 7634166F1D3F13E700EA57FE; 129 | productRefGroup = 763416791D3F13E700EA57FE /* Products */; 130 | projectDirPath = ""; 131 | projectRoot = ""; 132 | targets = ( 133 | 763416771D3F13E700EA57FE /* NinaSelectionView */, 134 | ); 135 | }; 136 | /* End PBXProject section */ 137 | 138 | /* Begin PBXResourcesBuildPhase section */ 139 | 763416761D3F13E700EA57FE /* Resources */ = { 140 | isa = PBXResourcesBuildPhase; 141 | buildActionMask = 2147483647; 142 | files = ( 143 | 763416A01D3F151200EA57FE /* Assets.xcassets in Resources */, 144 | 763416A11D3F151200EA57FE /* LaunchScreen.storyboard in Resources */, 145 | ); 146 | runOnlyForDeploymentPostprocessing = 0; 147 | }; 148 | /* End PBXResourcesBuildPhase section */ 149 | 150 | /* Begin PBXSourcesBuildPhase section */ 151 | 763416741D3F13E700EA57FE /* Sources */ = { 152 | isa = PBXSourcesBuildPhase; 153 | buildActionMask = 2147483647; 154 | files = ( 155 | 763416AC1D3F1BE100EA57FE /* NinaSelectionView.m in Sources */, 156 | 763416A51D3F151200EA57FE /* ViewController.m in Sources */, 157 | 763416A41D3F151200EA57FE /* main.m in Sources */, 158 | 7634169F1D3F151200EA57FE /* AppDelegate.m in Sources */, 159 | ); 160 | runOnlyForDeploymentPostprocessing = 0; 161 | }; 162 | /* End PBXSourcesBuildPhase section */ 163 | 164 | /* Begin PBXVariantGroup section */ 165 | 763416971D3F151200EA57FE /* LaunchScreen.storyboard */ = { 166 | isa = PBXVariantGroup; 167 | children = ( 168 | 763416981D3F151200EA57FE /* Base */, 169 | ); 170 | name = LaunchScreen.storyboard; 171 | sourceTree = ""; 172 | }; 173 | /* End PBXVariantGroup section */ 174 | 175 | /* Begin XCBuildConfiguration section */ 176 | 7634168D1D3F13E700EA57FE /* Debug */ = { 177 | isa = XCBuildConfiguration; 178 | buildSettings = { 179 | ALWAYS_SEARCH_USER_PATHS = NO; 180 | CLANG_ANALYZER_NONNULL = YES; 181 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 182 | CLANG_CXX_LIBRARY = "libc++"; 183 | CLANG_ENABLE_MODULES = YES; 184 | CLANG_ENABLE_OBJC_ARC = YES; 185 | CLANG_WARN_BOOL_CONVERSION = YES; 186 | CLANG_WARN_CONSTANT_CONVERSION = YES; 187 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 188 | CLANG_WARN_EMPTY_BODY = YES; 189 | CLANG_WARN_ENUM_CONVERSION = YES; 190 | CLANG_WARN_INT_CONVERSION = YES; 191 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 192 | CLANG_WARN_UNREACHABLE_CODE = YES; 193 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 194 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 195 | COPY_PHASE_STRIP = NO; 196 | DEBUG_INFORMATION_FORMAT = dwarf; 197 | ENABLE_STRICT_OBJC_MSGSEND = YES; 198 | ENABLE_TESTABILITY = YES; 199 | GCC_C_LANGUAGE_STANDARD = gnu99; 200 | GCC_DYNAMIC_NO_PIC = NO; 201 | GCC_NO_COMMON_BLOCKS = YES; 202 | GCC_OPTIMIZATION_LEVEL = 0; 203 | GCC_PREPROCESSOR_DEFINITIONS = ( 204 | "DEBUG=1", 205 | "$(inherited)", 206 | ); 207 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 208 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 209 | GCC_WARN_UNDECLARED_SELECTOR = YES; 210 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 211 | GCC_WARN_UNUSED_FUNCTION = YES; 212 | GCC_WARN_UNUSED_VARIABLE = YES; 213 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 214 | MTL_ENABLE_DEBUG_INFO = YES; 215 | ONLY_ACTIVE_ARCH = YES; 216 | SDKROOT = iphoneos; 217 | TARGETED_DEVICE_FAMILY = "1,2"; 218 | }; 219 | name = Debug; 220 | }; 221 | 7634168E1D3F13E700EA57FE /* Release */ = { 222 | isa = XCBuildConfiguration; 223 | buildSettings = { 224 | ALWAYS_SEARCH_USER_PATHS = NO; 225 | CLANG_ANALYZER_NONNULL = YES; 226 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 227 | CLANG_CXX_LIBRARY = "libc++"; 228 | CLANG_ENABLE_MODULES = YES; 229 | CLANG_ENABLE_OBJC_ARC = YES; 230 | CLANG_WARN_BOOL_CONVERSION = YES; 231 | CLANG_WARN_CONSTANT_CONVERSION = YES; 232 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 233 | CLANG_WARN_EMPTY_BODY = YES; 234 | CLANG_WARN_ENUM_CONVERSION = YES; 235 | CLANG_WARN_INT_CONVERSION = YES; 236 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 237 | CLANG_WARN_UNREACHABLE_CODE = YES; 238 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 239 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 240 | COPY_PHASE_STRIP = NO; 241 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 242 | ENABLE_NS_ASSERTIONS = NO; 243 | ENABLE_STRICT_OBJC_MSGSEND = YES; 244 | GCC_C_LANGUAGE_STANDARD = gnu99; 245 | GCC_NO_COMMON_BLOCKS = YES; 246 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 247 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 248 | GCC_WARN_UNDECLARED_SELECTOR = YES; 249 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 250 | GCC_WARN_UNUSED_FUNCTION = YES; 251 | GCC_WARN_UNUSED_VARIABLE = YES; 252 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 253 | MTL_ENABLE_DEBUG_INFO = NO; 254 | SDKROOT = iphoneos; 255 | TARGETED_DEVICE_FAMILY = "1,2"; 256 | VALIDATE_PRODUCT = YES; 257 | }; 258 | name = Release; 259 | }; 260 | 763416901D3F13E700EA57FE /* Debug */ = { 261 | isa = XCBuildConfiguration; 262 | buildSettings = { 263 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 264 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = "Brand Assets"; 265 | CODE_SIGN_IDENTITY = "iPhone Developer"; 266 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 267 | INFOPLIST_FILE = "$(SRCROOT)/Example/Info.plist"; 268 | IPHONEOS_DEPLOYMENT_TARGET = 7.1; 269 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 270 | PRODUCT_BUNDLE_IDENTIFIER = RamWire.NinaSelectionView; 271 | PRODUCT_NAME = "$(TARGET_NAME)"; 272 | PROVISIONING_PROFILE = ""; 273 | }; 274 | name = Debug; 275 | }; 276 | 763416911D3F13E700EA57FE /* Release */ = { 277 | isa = XCBuildConfiguration; 278 | buildSettings = { 279 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 280 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = "Brand Assets"; 281 | CODE_SIGN_IDENTITY = "iPhone Developer"; 282 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 283 | INFOPLIST_FILE = "$(SRCROOT)/Example/Info.plist"; 284 | IPHONEOS_DEPLOYMENT_TARGET = 7.1; 285 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 286 | PRODUCT_BUNDLE_IDENTIFIER = RamWire.NinaSelectionView; 287 | PRODUCT_NAME = "$(TARGET_NAME)"; 288 | PROVISIONING_PROFILE = ""; 289 | }; 290 | name = Release; 291 | }; 292 | /* End XCBuildConfiguration section */ 293 | 294 | /* Begin XCConfigurationList section */ 295 | 763416731D3F13E700EA57FE /* Build configuration list for PBXProject "NinaSelectionView" */ = { 296 | isa = XCConfigurationList; 297 | buildConfigurations = ( 298 | 7634168D1D3F13E700EA57FE /* Debug */, 299 | 7634168E1D3F13E700EA57FE /* Release */, 300 | ); 301 | defaultConfigurationIsVisible = 0; 302 | defaultConfigurationName = Release; 303 | }; 304 | 7634168F1D3F13E700EA57FE /* Build configuration list for PBXNativeTarget "NinaSelectionView" */ = { 305 | isa = XCConfigurationList; 306 | buildConfigurations = ( 307 | 763416901D3F13E700EA57FE /* Debug */, 308 | 763416911D3F13E700EA57FE /* Release */, 309 | ); 310 | defaultConfigurationIsVisible = 0; 311 | defaultConfigurationName = Release; 312 | }; 313 | /* End XCConfigurationList section */ 314 | }; 315 | rootObject = 763416701D3F13E700EA57FE /* Project object */; 316 | } 317 | -------------------------------------------------------------------------------- /NinaSelectionView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /NinaSelectionView.xcodeproj/project.xcworkspace/xcuserdata/RamWire.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RamWire/NinaSelectionView/fee20bcf2c1f6c8dbdbf1dd09c414f4f5fb20200/NinaSelectionView.xcodeproj/project.xcworkspace/xcuserdata/RamWire.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /NinaSelectionView.xcodeproj/xcshareddata/xcschemes/NinaSelectionView.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /NinaSelectionView.xcodeproj/xcuserdata/RamWire.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 14 | 15 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 28 | 40 | 41 | 42 | 44 | 56 | 57 | 58 | 60 | 72 | 73 | 74 | 76 | 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /NinaSelectionView.xcodeproj/xcuserdata/RamWire.xcuserdatad/xcschemes/NinaSelectionView.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /NinaSelectionView.xcodeproj/xcuserdata/RamWire.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | NinaSelectionView.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 763416771D3F13E700EA57FE 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /NinaSelectionView.xcodeproj/xcuserdata/renrun.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /NinaSelectionView.xcodeproj/xcuserdata/renrun.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | NinaSelectionView.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 763416771D3F13E700EA57FE 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /NinaSelectionView/NinaSelectionView.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright (c) 2015-2016 RamWire ( https://github.com/RamWire ) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #import 24 | 25 | typedef NS_ENUM(NSInteger, NinaPopDirection) { 26 | /**< Pop from above **/ 27 | NinaPopFromAboveToTop = 0, 28 | NinaPopFromAboveToMiddle = 1, 29 | NinaPopFromAboveToBottom = 2, 30 | /**< Pop from below **/ 31 | NinaPopFromBelowToTop = 3, 32 | NinaPopFromBelowToMiddle = 4, 33 | NinaPopFromBelowToBottom = 5, 34 | /**< Pop from left **/ 35 | NinaPopFromLeftToTop = 6, 36 | NinaPopFromLeftToMiddle = 7, 37 | NinaPopFromLeftToBottom = 8, 38 | /**< Pop from right **/ 39 | NinaPopFromRightToTop = 9, 40 | NinaPopFromRightToMiddle = 10, 41 | NinaPopFromRightToBottom = 11, 42 | }; 43 | 44 | @protocol NinaSelectionDelegate 45 | 46 | @optional 47 | /** 48 | * NinaSelectionDelegate 49 | * 50 | * @param button Select Button. 51 | */ 52 | - (void)selectNinaAction:(UIButton *)button; 53 | 54 | @end 55 | 56 | @interface NinaSelectionView : UIScrollView 57 | /** 58 | * NinaSelectionView init method. 59 | * 60 | * @param titles titles showing on NinaSelectionView. 61 | * @param direction NinaSelection pops direction. 62 | * 63 | */ 64 | - (instancetype)initWithTitles:(NSArray *)titles PopDirection:(NinaPopDirection)direction; 65 | /** 66 | * Show or dismiss NinaSelectionView when you needed.(No spring effect) 67 | * 68 | * @param duration NinaSelectionView pop animation time. 69 | */ 70 | - (void)showOrDismissNinaViewWithDuration:(NSTimeInterval)duration; 71 | /** 72 | * Show or dismiss NinaSelectionView when you needed.(With spring effect) 73 | * 74 | * @param duration NinaSelectionView pop animation time. 75 | * @param dampingRatio NinaSelectionView damping level 76 | * @param velocity init pop speed level 77 | */ 78 | - (void)showOrDismissNinaViewWithDuration:(NSTimeInterval)duration usingNinaSpringWithDamping:(CGFloat)dampingRatio initialNinaSpringVelocity:(CGFloat)velocity; 79 | 80 | /** 81 | * Default Selected button tag number.(Range from 1~...) 82 | */ 83 | @property (nonatomic, assign) NSInteger defaultSelected; 84 | /** 85 | * Show shadowEffect or not.Default shadowAlpha is 0.5. 86 | */ 87 | @property (nonatomic, assign) BOOL shadowEffect; 88 | /** 89 | * If turn on shadowEffect,you can set alpha for shadowView. 90 | */ 91 | @property (nonatomic, assign) CGFloat shadowAlpha; 92 | /** 93 | * Set NinaSelection Pop Y. 94 | */ 95 | @property (nonatomic, assign) CGFloat nina_popY; 96 | /** 97 | * NinaSelectionDelegate 98 | */ 99 | @property (nonatomic, weak)idninaSelectionDelegate; 100 | 101 | @end 102 | -------------------------------------------------------------------------------- /NinaSelectionView/NinaSelectionView.m: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright (c) 2015-2016 RamWire ( https://github.com/RamWire ) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #import "NinaSelectionView.h" 24 | #import "UIParameter.h" 25 | 26 | @interface NinaSelectionView() 27 | @property (nonatomic, strong) UIView *shadowView; 28 | @property (nonatomic, strong) UIView *bottomLine; 29 | @end 30 | 31 | @implementation NinaSelectionView { 32 | NSInteger selectionHeight; 33 | NinaPopDirection ninaDireciton; 34 | NSInteger columnNum; 35 | NSArray *ninaTitles; 36 | NSMutableArray *buttonArray; 37 | double tapDuration; 38 | CGFloat tapDamping; 39 | CGFloat tapVelocity; 40 | BOOL showState; 41 | BOOL verticalScrollMode; 42 | BOOL horizontalScrollMode; 43 | CGPoint ninaStartPoint; 44 | CGPoint ninaOriginPoint; 45 | BOOL ninaContain; 46 | } 47 | 48 | - (instancetype)initWithTitles:(NSArray *)titles PopDirection:(NinaPopDirection)direction { 49 | if (self = [super init]) { 50 | if (titles.count > 0) { 51 | self.hidden = YES; 52 | self.backgroundColor = [UIColor whiteColor]; 53 | buttonArray = [NSMutableArray array]; 54 | ninaDireciton = direction; 55 | ninaTitles = titles; 56 | selectionHeight = 0; 57 | columnNum = 0; 58 | if (titles.count % PerNum == 0) { 59 | columnNum = titles.count / PerNum; 60 | }else { 61 | columnNum = titles.count / PerNum + 1; 62 | } 63 | selectionHeight = Nina_Button_TopSpace * 2 + (Nina_Button_Height + Nina_Button_Space) * columnNum - Nina_Button_Space; 64 | if (selectionHeight > FUll_CONTENT_HEIGHT_WITHOUT_TAB) { 65 | verticalScrollMode = YES; 66 | } 67 | if (Nina_View_X < 0) { 68 | horizontalScrollMode = YES; 69 | } 70 | CGFloat defaultY = 0; 71 | CGFloat defaultX = horizontalScrollMode?0:Nina_View_X; 72 | switch (direction / 3) { 73 | case 0: 74 | defaultY = -(selectionHeight); 75 | break; 76 | case 1: 77 | defaultY = selectionHeight + FUll_VIEW_HEIGHT; 78 | break; 79 | case 2: 80 | defaultX = -(Nina_View_Width); 81 | if (direction == 7) { 82 | defaultY = verticalScrollMode?0:(FUll_CONTENT_HEIGHT_WITHOUT_TAB - selectionHeight) / 2; 83 | }else if (direction == 8) { 84 | defaultY = verticalScrollMode?0:FUll_CONTENT_HEIGHT_WITHOUT_TAB - selectionHeight; 85 | } 86 | break; 87 | case 3: 88 | defaultX = (FUll_VIEW_WIDTH); 89 | if (direction == 10) { 90 | defaultY = verticalScrollMode?0:(FUll_CONTENT_HEIGHT_WITHOUT_TAB - selectionHeight) / 2; 91 | }else if (direction == 11) { 92 | defaultY = verticalScrollMode?0:FUll_CONTENT_HEIGHT_WITHOUT_TAB - selectionHeight; 93 | } 94 | break; 95 | default: 96 | break; 97 | } 98 | if (verticalScrollMode) { 99 | self.alwaysBounceVertical = YES; 100 | self.showsVerticalScrollIndicator = YES; 101 | if (horizontalScrollMode) { 102 | self.bounces = NO; 103 | self.contentSize = CGSizeMake(Nina_View_Width, selectionHeight); 104 | self.alwaysBounceHorizontal = YES; 105 | self.showsHorizontalScrollIndicator = YES; 106 | self.frame = CGRectMake(defaultX, defaultY, FUll_VIEW_WIDTH, FUll_CONTENT_HEIGHT_WITHOUT_TAB); 107 | }else { 108 | self.contentSize = CGSizeMake(0, selectionHeight); 109 | self.frame = CGRectMake(defaultX, defaultY, Nina_View_Width, FUll_CONTENT_HEIGHT_WITHOUT_TAB); 110 | } 111 | }else { 112 | if (horizontalScrollMode) { 113 | self.contentSize = CGSizeMake(Nina_View_Width, 0); 114 | self.alwaysBounceHorizontal = YES; 115 | self.showsHorizontalScrollIndicator = YES; 116 | self.frame = CGRectMake(defaultX, defaultY, FUll_VIEW_WIDTH, selectionHeight); 117 | }else { 118 | self.scrollEnabled = NO; 119 | self.frame = CGRectMake(defaultX, defaultY, Nina_View_Width, selectionHeight); 120 | } 121 | } 122 | [self createSelectionButton]; 123 | [self addSubview:self.bottomLine]; 124 | }else { 125 | NSLog(@"Titles-array's count should not be zero."); 126 | } 127 | } 128 | return self; 129 | } 130 | 131 | #pragma mark - SetMethod 132 | - (void)setDefaultSelected:(NSInteger)defaultSelected { 133 | if (buttonArray.count > 0) { 134 | _defaultSelected = defaultSelected; 135 | UIButton *selectBtn = buttonArray[defaultSelected - 1]; 136 | [self ninaSelectChangeColor:selectBtn]; 137 | } 138 | } 139 | 140 | - (void)setShadowEffect:(BOOL)shadowEffect { 141 | _shadowEffect = shadowEffect; 142 | if (_shadowEffect) { 143 | [self.superview insertSubview:self.shadowView belowSubview:self]; 144 | self.shadowView.alpha = 0.f; 145 | UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapToDismissNinaView)]; 146 | [self.shadowView addGestureRecognizer:tap]; 147 | } 148 | } 149 | 150 | - (void)setShadowAlpha:(CGFloat)shadowAlpha { 151 | if (_shadowEffect && shadowAlpha > 0.f) { 152 | _shadowAlpha = shadowAlpha; 153 | self.shadowView.alpha = _shadowAlpha; 154 | }else { 155 | NSLog(@"You must set ShadowEffect to YES then shadowAlpha should be worked."); 156 | } 157 | } 158 | 159 | - (void)setNina_popY:(CGFloat)nina_popY { 160 | if (nina_popY > 0 && nina_popY < FUll_CONTENT_HEIGHT_WITHOUT_TAB - SELFHEIGHT) { 161 | _nina_popY = nina_popY; 162 | }else { 163 | NSLog(@"Hey,your nina_popY is not fit for show NinaSelectionView."); 164 | } 165 | } 166 | 167 | #pragma mark - LazyLoad 168 | - (UIView *)shadowView { 169 | if (!_shadowView) { 170 | _shadowView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, FUll_VIEW_WIDTH, FUll_CONTENT_HEIGHT_WITHOUT_TAB)]; 171 | _shadowView.backgroundColor = [UIColor blackColor]; 172 | _shadowView.alpha = 0.5f; 173 | } 174 | return _shadowView; 175 | } 176 | 177 | - (UIView *)bottomLine { 178 | if (!_bottomLine) { 179 | _bottomLine = [[UIView alloc] initWithFrame:CGRectMake(0,selectionHeight - 2, Nina_View_Width, 2)]; 180 | _bottomLine.backgroundColor = UIColorFromRGB(0xb2b2b2); 181 | } 182 | return _bottomLine; 183 | } 184 | 185 | #pragma mark - NinaSelectionMethod 186 | - (void)showOrDismissNinaViewWithDuration:(NSTimeInterval)duration { 187 | NSArray *locateArray = [self showOrDismissDetailMethodWithDuration:duration]; 188 | if (locateArray.count != 2) { 189 | return; 190 | } 191 | CGFloat ninaViewX = [locateArray[0] floatValue]; 192 | CGFloat ninaViewY = [locateArray[1] floatValue]; 193 | if (verticalScrollMode) { 194 | [UIView animateWithDuration:duration animations:^{ 195 | self.frame = CGRectMake(ninaViewX, ninaViewY, (horizontalScrollMode?FUll_VIEW_WIDTH:Nina_View_Width), FUll_CONTENT_HEIGHT_WITHOUT_TAB); 196 | }completion:^(BOOL finished) { 197 | if (showState == NO) { 198 | self.hidden = YES; 199 | } 200 | }]; 201 | }else { 202 | if ((ninaDireciton == 1 || ninaDireciton == 4 || ninaDireciton == 7 || ninaDireciton == 10) && showState) { 203 | ninaViewX = horizontalScrollMode ?0:Nina_View_X; 204 | ninaViewY = verticalScrollMode?0:(FUll_CONTENT_HEIGHT_WITHOUT_TAB - selectionHeight) / 2; 205 | } 206 | [UIView animateWithDuration:duration animations:^{ 207 | self.frame = CGRectMake(ninaViewX, (((_nina_popY > 0) && showState == YES)?_nina_popY:ninaViewY), (horizontalScrollMode?FUll_VIEW_WIDTH:Nina_View_Width), selectionHeight); 208 | } completion:^(BOOL finished) { 209 | if (showState == NO) { 210 | self.hidden = YES; 211 | } 212 | }]; 213 | } 214 | } 215 | 216 | - (void)showOrDismissNinaViewWithDuration:(NSTimeInterval)duration usingNinaSpringWithDamping:(CGFloat)dampingRatio initialNinaSpringVelocity:(CGFloat)velocity { 217 | NSArray *locateArray = [self showOrDismissDetailMethodWithDuration:duration]; 218 | if (locateArray.count != 2) { 219 | return; 220 | } 221 | CGFloat ninaViewX = [locateArray[0] floatValue]; 222 | CGFloat ninaViewY = [locateArray[1] floatValue]; 223 | CGFloat dampingOrNot = ((dampingRatio < 1) && (dampingRatio > 0))?dampingRatio:0.5; 224 | CGFloat damping = showState?dampingOrNot:1; 225 | CGFloat VelocityNum = ((velocity < 1) && (velocity > 0))?velocity:0.75; 226 | tapDamping = damping; 227 | tapVelocity = VelocityNum; 228 | if (verticalScrollMode) { 229 | [UIView animateWithDuration:duration delay:0 usingSpringWithDamping:damping initialSpringVelocity:VelocityNum options:UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionBeginFromCurrentState animations:^{ 230 | self.frame = CGRectMake(ninaViewX, ninaViewY, (horizontalScrollMode?FUll_VIEW_WIDTH:Nina_View_Width), FUll_CONTENT_HEIGHT_WITHOUT_TAB); 231 | }completion:^(BOOL finished) { 232 | if (showState == NO) { 233 | self.hidden = YES; 234 | } 235 | }]; 236 | }else { 237 | if ((ninaDireciton == 1 || ninaDireciton == 4 || ninaDireciton == 7 || ninaDireciton == 10) && showState) { 238 | ninaViewX = horizontalScrollMode ?0:Nina_View_X; 239 | ninaViewY = verticalScrollMode?0:(FUll_CONTENT_HEIGHT_WITHOUT_TAB - selectionHeight) / 2; 240 | } 241 | [UIView animateWithDuration:duration delay:0 usingSpringWithDamping:damping initialSpringVelocity:VelocityNum options:UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionBeginFromCurrentState animations:^{ 242 | self.frame = CGRectMake(ninaViewX, (((_nina_popY > 0) && showState == YES)?_nina_popY:ninaViewY), (horizontalScrollMode?FUll_VIEW_WIDTH:Nina_View_Width), selectionHeight); 243 | } completion:^(BOOL finished) { 244 | if (showState == NO) { 245 | self.hidden = YES; 246 | } 247 | }]; 248 | } 249 | } 250 | 251 | #pragma mark - PrivateMethod 252 | - (NSArray *)showOrDismissDetailMethodWithDuration:(NSTimeInterval)duration { 253 | tapDuration = duration; 254 | CGFloat ninaViewY = 0; 255 | CGFloat ninaViewX = horizontalScrollMode ?0:Nina_View_X; 256 | if (ninaDireciton == 2 || ninaDireciton == 5 || ninaDireciton == 8 || ninaDireciton == 11) { 257 | if (selectionHeight <= FUll_CONTENT_HEIGHT_WITHOUT_TAB) { 258 | ninaViewY = FUll_CONTENT_HEIGHT_WITHOUT_TAB - selectionHeight; 259 | } 260 | }else if (ninaDireciton == 7 || ninaDireciton == 10) { 261 | ninaViewY = verticalScrollMode?0:(FUll_CONTENT_HEIGHT_WITHOUT_TAB - selectionHeight) / 2; 262 | }else if (ninaDireciton == 8 || ninaDireciton == 11) { 263 | ninaViewY = verticalScrollMode?0:FUll_CONTENT_HEIGHT_WITHOUT_TAB - selectionHeight; 264 | } 265 | if ((self.frame.origin.y == 0 && self.frame.origin.x == (horizontalScrollMode ?0:Nina_View_X)) || (self.frame.origin.y == _nina_popY && self.frame.origin.x == (horizontalScrollMode ?0:Nina_View_X)) || (self.frame.origin.x == (horizontalScrollMode ?0:Nina_View_X) && self.frame.origin.y == (FUll_CONTENT_HEIGHT_WITHOUT_TAB - selectionHeight) / 2) || (self.frame.origin.y == FUll_CONTENT_HEIGHT_WITHOUT_TAB - selectionHeight && self.frame.origin.x == (horizontalScrollMode ?0:Nina_View_X))) { 266 | showState = NO; 267 | if (_shadowEffect) { 268 | [UIView animateWithDuration:duration animations:^{ 269 | self.shadowView.alpha = 0.f; 270 | }]; 271 | } 272 | switch (ninaDireciton / 3) { 273 | case 0: 274 | ninaViewY = verticalScrollMode?(-(FUll_CONTENT_HEIGHT_WITHOUT_TAB)):(-(selectionHeight)); 275 | break; 276 | case 1: 277 | ninaViewY = verticalScrollMode?(FUll_CONTENT_HEIGHT_WITHOUT_TAB + FUll_VIEW_HEIGHT):(selectionHeight + FUll_VIEW_HEIGHT); 278 | break; 279 | case 2: 280 | ninaViewX = -(Nina_View_Width); 281 | break; 282 | case 3: 283 | ninaViewX = (FUll_VIEW_WIDTH); 284 | break; 285 | default: 286 | break; 287 | } 288 | }else { 289 | self.hidden = NO; 290 | showState = YES; 291 | [self.superview bringSubviewToFront:self]; 292 | if (_shadowEffect) { 293 | [self.superview insertSubview:self.shadowView belowSubview:self]; 294 | [UIView animateWithDuration:duration animations:^{ 295 | if (_shadowAlpha > 0.f) { 296 | self.shadowView.alpha = _shadowAlpha; 297 | }else { 298 | self.shadowView.alpha = 0.5f; 299 | } 300 | }]; 301 | } 302 | } 303 | return @[[NSString stringWithFormat:@"%f",ninaViewX],[NSString stringWithFormat:@"%f",ninaViewY]]; 304 | } 305 | 306 | - (void)createSelectionButton { 307 | for (int i = 0; i < ninaTitles.count; i++) { 308 | UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; 309 | button.tag = i + 1; 310 | if(i < PerNum && i >= 0){ 311 | button.frame = CGRectMake(Nina_Button_X + i * (Nina_Button_Width + Nina_Button_Space) , Nina_Button_TopSpace, Nina_Button_Width, Nina_Button_Height); 312 | }else { 313 | button.frame = CGRectMake(Nina_Button_X + (i % PerNum) * (Nina_Button_Width + Nina_Button_Space) , Nina_Button_TopSpace + (Nina_Button_Height + Nina_Button_Space) * (i / PerNum), Nina_Button_Width, Nina_Button_Height); 314 | } 315 | [button addTarget:self action:@selector(ninaButtonAciton:) forControlEvents:UIControlEventTouchUpInside]; 316 | button.backgroundColor = [UIColor whiteColor]; 317 | [button setTitle:[ninaTitles objectAtIndex:i] forState:UIControlStateNormal]; 318 | [button setTitleColor:UIColorFromRGB(0x656667) forState:UIControlStateNormal]; 319 | button.titleLabel.font = [UIFont systemFontOfSize:14]; 320 | button.layer.cornerRadius = 4; 321 | button.layer.borderColor = UIColorFromRGB(0xDBDCDD).CGColor; 322 | button.layer.borderWidth = 1; 323 | [self addSubview:button]; 324 | UILongPressGestureRecognizer *longGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(buttonLongPressed:)]; 325 | [button addGestureRecognizer:longGesture]; 326 | [buttonArray addObject:button]; 327 | } 328 | } 329 | 330 | #pragma mark - UILongPressGestureRecognizerAction 331 | - (void)buttonLongPressed:(UILongPressGestureRecognizer *)sender { 332 | UIButton *btn = (UIButton *)sender.view; 333 | if (sender.state == UIGestureRecognizerStateBegan) { 334 | ninaStartPoint = [sender locationInView:sender.view]; 335 | ninaOriginPoint = btn.center; 336 | [UIView animateWithDuration:Hold_Duration animations:^{ 337 | btn.transform = CGAffineTransformMakeScale(1.1, 1.1); 338 | btn.alpha = 0.7; 339 | }]; 340 | }else if (sender.state == UIGestureRecognizerStateChanged) { 341 | CGPoint newDragPoint = [sender locationInView:sender.view]; 342 | CGFloat dragChangeX = newDragPoint.x - ninaStartPoint.x; 343 | CGFloat dragChangeY = newDragPoint.y - ninaStartPoint.y; 344 | btn.center = CGPointMake(btn.center.x + dragChangeX,btn.center.y + dragChangeY); 345 | NSInteger index = [self buttonIndexOfPoint:btn.center withDragButton:btn]; 346 | if (index < 0) { 347 | ninaContain = NO; 348 | }else { 349 | [UIView animateWithDuration:Hold_Duration animations:^{ 350 | CGPoint tempPoint = CGPointZero; 351 | UIButton *button = buttonArray[index]; 352 | tempPoint = button.center; 353 | button.center = ninaOriginPoint; 354 | btn.center = tempPoint; 355 | ninaOriginPoint = btn.center; 356 | ninaContain = YES; 357 | }]; 358 | } 359 | }else if (sender.state == UIGestureRecognizerStateEnded) { 360 | [UIView animateWithDuration:Hold_Duration animations:^{ 361 | btn.transform = CGAffineTransformIdentity; 362 | btn.alpha = 1.0; 363 | if (!ninaContain) { 364 | btn.center = ninaOriginPoint; 365 | } 366 | }]; 367 | } 368 | } 369 | 370 | - (NSInteger)buttonIndexOfPoint:(CGPoint)point withDragButton:(UIButton *)btn { 371 | for (NSInteger i = 0; i < buttonArray.count; i++) { 372 | UIButton *button = buttonArray[i]; 373 | if (button != btn) { 374 | if (CGRectContainsPoint(button.frame, point)) { 375 | return i; 376 | } 377 | } 378 | } 379 | return -1; 380 | } 381 | 382 | #pragma mark - NinaButtonAction 383 | - (void)ninaButtonAciton:(UIButton *)button { 384 | [self ninaSelectChangeColor:button]; 385 | if ([self.ninaSelectionDelegate respondsToSelector:@selector(selectNinaAction:)]) { 386 | [self.ninaSelectionDelegate selectNinaAction:button]; 387 | } 388 | } 389 | 390 | #pragma mark - SelectColorChangeAction 391 | - (void)ninaSelectChangeColor:(UIButton *)changeBtn { 392 | for (NSInteger i = 0; i < buttonArray.count; i++) { 393 | UIButton *whiteButton = buttonArray[i]; 394 | whiteButton.titleLabel.textColor = UIColorFromRGB(0x656667); 395 | whiteButton.backgroundColor = [UIColor whiteColor]; 396 | whiteButton.layer.borderColor = UIColorFromRGB(0xDBDCDD).CGColor; 397 | } 398 | [changeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; 399 | changeBtn.backgroundColor = [UIColor colorWithRed:95/255.0f green:178/255.0f blue:244/255.0f alpha:1.0f]; 400 | changeBtn.layer.borderColor = [UIColor whiteColor].CGColor; 401 | } 402 | 403 | #pragma mark - TapAction 404 | - (void)tapToDismissNinaView { 405 | if (tapDamping > 0 && tapVelocity > 0) { 406 | [self showOrDismissNinaViewWithDuration:tapDuration usingNinaSpringWithDamping:tapDamping initialNinaSpringVelocity:tapVelocity]; 407 | }else { 408 | [self showOrDismissNinaViewWithDuration:tapDuration]; 409 | } 410 | } 411 | 412 | @end 413 | -------------------------------------------------------------------------------- /NinaSelectionView/UIParameter.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright (c) 2015-2016 RamWire ( https://github.com/RamWire ) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #ifndef UIParameter_h 24 | #define UIParameter_h 25 | 26 | //RGB Color 27 | #define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0] 28 | 29 | //FullScreen 30 | #define FUll_VIEW_WIDTH ([[UIScreen mainScreen] bounds].size.width) 31 | #define FUll_VIEW_HEIGHT ([[UIScreen mainScreen] bounds].size.height) 32 | #define FUll_CONTENT_HEIGHT_WITHOUT_TAB ([[UIScreen mainScreen] bounds].size.height-64) 33 | #define SELFWIDTH self.frame.size.width 34 | #define SELFHEIGHT self.frame.size.height 35 | #define NinaNavigationBarHeight 64 36 | 37 | //NinaSelectionView Parameters 38 | #define PerNum 3 //Better between 2~5 39 | #define Nina_View_Width FUll_VIEW_WIDTH 40 | #define Nina_View_X (FUll_VIEW_WIDTH - Nina_View_Width) / 2 41 | #define Nina_Button_X 15 42 | #define Nina_Button_Height 30 43 | #define Nina_Button_Width (Nina_View_Width - 2 * Nina_Button_X - (PerNum - 1) * Nina_Button_Space) / PerNum 44 | #define Nina_Button_TopSpace 17.5 45 | #define Nina_Button_Space 10 46 | #define Hold_Duration 0.2 47 | 48 | #endif /* UIParameter_h */ 49 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![image](https://github.com/RamWire/NinaSelectionView/blob/master/Example/Gifs/Sliceheader2.png) 2 | [![Language](https://img.shields.io/badge/Language-%20Objective--C%20-orange.svg)](https://img.shields.io/badge/Language-%20Objective--C%20-orange.svg) 3 | [![Pod Version](http://img.shields.io/cocoapods/v/NinaSelectionView.svg?style=flat)](http://cocoadocs.org/docsets/NinaSelectionView/) 4 | [![Pod Platform](http://img.shields.io/cocoapods/p/NinaSelectionView.svg?style=flat)](http://cocoadocs.org/docsets/NinaSelectionView/) 5 | [![Pod License](http://img.shields.io/cocoapods/l/NinaSelectionView.svg?style=flat)](https://www.apache.org/licenses/LICENSE-2.0.html) 6 | [![Build Status](https://travis-ci.org/RamWire/NinaSelectionView.svg?branch=master)](https://travis-ci.org/RamWire/NinaSelectionView)
7 | 🇨🇳[中文文档说明](https://github.com/RamWire/NinaSelectionView/blob/master/README_CN.md) 8 | * A fantastic way to select your buttons by NinaSelectionView. 9 | 10 | ## Features 11 | - [x] Low coupling to pop NinaSelectionView,just with one-line code methods to use it. 12 | - [x] Like AliPay pop style,and you can use it more flexible. 13 | - [x] Supports 12 pop styles,you can pop from above,below,left and right. 14 | - [x] Pop to anywhere as you wish. 15 | - [x] Support scroll when NinaSelection's height or width is longer than screen's. 16 | - [x] NinaSelectionView buttons can drag and exchange as you wish. 17 | - [x] Support Spring animation and normal animation. 18 | 19 | ## Preview 20 | ### Pop Styles 21 | ![image](https://github.com/RamWire/NinaSelectionView/blob/master/Example/Gifs/NinaSelectionViewAbove.gif) 22 | ![image](https://github.com/RamWire/NinaSelectionView/blob/master/Example/Gifs/NinaSelectionViewBelow.gif) 23 | ![image](https://github.com/RamWire/NinaSelectionView/blob/master/Example/Gifs/NinaSelectionViewLeft.gif) 24 | ![image](https://github.com/RamWire/NinaSelectionView/blob/master/Example/Gifs/NinaSelectionViewRight.gif) 25 | ### Drag Feature 26 | ![image](https://github.com/RamWire/NinaSelectionView/blob/master/Example/Gifs/NinaSelectionViewDrag.gif) 27 | ### LongScrollState 28 | ![image](https://github.com/RamWire/NinaSelectionView/blob/master/Example/Gifs/NinaSelectionViewHorizontal.gif) 29 | ![image](https://github.com/RamWire/NinaSelectionView/blob/master/Example/Gifs/NinaSelectionViewVertical.gif) 30 | ![image](https://github.com/RamWire/NinaSelectionView/blob/master/Example/Gifs/NinaSelectionViewScroll.gif) 31 | 32 | ## Installation 33 | 34 | Drop in the Classes folder to your Xcode project. 35 | You can also use cocoapods. 36 | 37 | #### Using [CocoaPods](http://cocoapods.org/) 38 | 39 | Add `pod 'NinaSelectionView'` to your `Podfile` and run `pod install`. 40 | 41 | ``` 42 | pod 'NinaSelectionView' 43 | ``` 44 | 45 | ## Usage 46 | You need add '**NinaSelectionView.h**'(**CocoaPods**) to your project.Then load the codes: 47 | ```objc 48 | NinaSelectionView *ninaSelectionView = [[NinaSelectionView alloc] initWithTitles:[self titlesArray] PopDirection:NinaPopFromAboveToTop]; 49 | [self.view addSubview:ninaSelectionView]; 50 | ``` 51 | Then when you wanna show or dismiss NinaSelectionView,you need use: 52 | ```objc 53 | [self.ninaSelectionView showOrDismissNinaViewWithDuration:0.5 usingNinaSpringWithDamping:0.8 initialNinaSpringVelocity:0.3]; 54 | ``` 55 | or 56 | ```objc 57 | [self.ninaSelectionView showOrDismissNinaViewWithDuration:0.5]; 58 | ``` 59 | Yeah,that's all! 60 | 61 | ### Other Settings and Tips 62 | * You can set necessary Array by following codes(please read the **Example** notes if you wanna to know more). 63 | ```objc 64 | NSArray *titleArray = @[ 65 | @"Curry", 66 | @"Thompson", 67 | @"Green", 68 | @"Iguodala", 69 | @"Durant" 70 | ]; 71 | ``` 72 | * To complete button actions,you need write **NinaSelectionDelegate** in your codes: 73 | ```objc 74 | - (void)selectNinaAction:(UIButton *)button { 75 | NSLog(@"Choose %li button",(long)button.tag); 76 | } 77 | ``` 78 | * You can also set defaultSelected button,start from 1. 79 | ```objc 80 | _ninaSelectionView.defaultSelected = 1; 81 | ``` 82 | * Meanwhile,shadow background also can be set.(You must set shadowEffect to **YES** first,then you can set shadowalpha) 83 | ```objc 84 | _ninaSelectionView.shadowEffect = YES; 85 | _ninaSelectionView.shadowAlpha = 0.4; 86 | ``` 87 | * If you wanna change buttons' parameters(column,width,height),you can go to UIParameter.h to change them.Meanwhile,you can change view' Y by using **nina_popY** in NinaSelectionView. 88 | 89 | ## Change Log 90 | #### v0.1.0 91 | First Release. 92 | 93 | ## FeedBack 94 | * If you find bugs in this project or any suggestions,hope you can give me feedback by issues or Email me to zhaogengda@126.com. 95 | 96 | ## Licence 97 | 98 | This project uses MIT License. 99 | -------------------------------------------------------------------------------- /README_CN.md: -------------------------------------------------------------------------------- 1 | ![image](https://github.com/RamWire/NinaSelectionView/blob/master/Example/Gifs/Sliceheader2.png) 2 | [![Language](https://img.shields.io/badge/Language-%20Objective--C%20-orange.svg)](https://img.shields.io/badge/Language-%20Objective--C%20-orange.svg) 3 | [![Pod Version](http://img.shields.io/cocoapods/v/NinaSelectionView.svg?style=flat)](http://cocoadocs.org/docsets/NinaSelectionView/) 4 | [![Pod Platform](http://img.shields.io/cocoapods/p/NinaSelectionView.svg?style=flat)](http://cocoadocs.org/docsets/NinaSelectionView/) 5 | [![Pod License](http://img.shields.io/cocoapods/l/NinaSelectionView.svg?style=flat)](https://www.apache.org/licenses/LICENSE-2.0.html) 6 | [![Build Status](https://travis-ci.org/RamWire/NinaSelectionView.svg?branch=master)](https://travis-ci.org/RamWire/NinaSelectionView)
7 | * 高灵活低耦合性地实现类似支付宝中余额宝累计收益界面筛选效果。 8 | 9 | ## 特点 10 | - [x] 低耦合弹出NinaSelectionView,只需要一句代码即可实现,简单易用。 11 | - [x] 高度接近支付宝筛选界面效果,您可以更灵活地去使用它。 12 | - [x] 现已支持12种不同的弹出方式,从上下左右都可以pop出。 13 | - [x] 几乎可以pop到界面的任何地方,具有高度的灵活性。 14 | - [x] 当您设置的NinaSelectionView大于屏幕大小,它是可以进行滑动来适应各个条件下的情况。 15 | - [x] 支持筛选按钮进行拖动和交换效果。 16 | - [x] 弹出的动画效果可以选择正常或者弹簧效果,参数由您控制。 17 | 18 | ## 预览 19 | ### 弹出效果图(节选部分) 20 | ![image](https://github.com/RamWire/NinaSelectionView/blob/master/Example/Gifs/NinaSelectionViewAbove.gif) 21 | ![image](https://github.com/RamWire/NinaSelectionView/blob/master/Example/Gifs/NinaSelectionViewBelow.gif) 22 | ![image](https://github.com/RamWire/NinaSelectionView/blob/master/Example/Gifs/NinaSelectionViewLeft.gif) 23 | ![image](https://github.com/RamWire/NinaSelectionView/blob/master/Example/Gifs/NinaSelectionViewRight.gif) 24 | ### 按钮拖动效果 25 | ![image](https://github.com/RamWire/NinaSelectionView/blob/master/Example/Gifs/NinaSelectionViewDrag.gif) 26 | ### 滑动模式 27 | ![image](https://github.com/RamWire/NinaSelectionView/blob/master/Example/Gifs/NinaSelectionViewHorizontal.gif) 28 | ![image](https://github.com/RamWire/NinaSelectionView/blob/master/Example/Gifs/NinaSelectionViewVertical.gif) 29 | ![image](https://github.com/RamWire/NinaSelectionView/blob/master/Example/Gifs/NinaSelectionViewScroll.gif) 30 | 31 | ## 安装 32 | 33 | 将NinaSelectionView文件夹拖入Xcode工程中 34 | 您也可以使用Cocoapods集成到您的工程中 35 | 36 | 37 | #### 使用 [CocoaPods](http://cocoapods.org/) 38 | 39 | 在您的podfile中加入`pod 'NinaSelectionView'` 然后运行`pod install`。 40 | 41 | ``` 42 | pod 'NinaSelectionView' 43 | ``` 44 | 45 | ## 使用 46 | 您需要将'**NinaSelectionView.h**'(**CocoaPods**)加入到您的工程中,然后执行下列代码: 47 | ```objc 48 | NinaSelectionView *ninaSelectionView = [[NinaSelectionView alloc] initWithTitles:[self titlesArray] PopDirection:NinaPopFromAboveToTop]; 49 | [self.view addSubview:ninaSelectionView]; 50 | ``` 51 | 接下来,当您想展示或者不展示NinaSelectionView时,您需要: 52 | ```objc 53 | [self.ninaSelectionView showOrDismissNinaViewWithDuration:0.5 usingNinaSpringWithDamping:0.8 initialNinaSpringVelocity:0.3]; 54 | ``` 55 | 或者 56 | ```objc 57 | [self.ninaSelectionView showOrDismissNinaViewWithDuration:0.5]; 58 | ``` 59 | 即可! 60 | 61 | ### 其他设置和补充 62 | * 在配置**NinaSelectionView**所需的数组时,您可以参照下方的代码进行配置(具体说明请看Example中的书写)。 63 | ```objc 64 | NSArray *titleArray = @[ 65 | @"Curry", 66 | @"Thompson", 67 | @"Green", 68 | @"Iguodala", 69 | @"Durant" 70 | ]; 71 | ``` 72 | * 在响应按钮们的点击事件时,您需要遵守**NinaSelectionDelegate**代理方法: 73 | ```objc 74 | - (void)selectNinaAction:(UIButton *)button { 75 | NSLog(@"Choose %li button",(long)button.tag); 76 | } 77 | ``` 78 | * 如果有默认选中按钮的需求,您可以对下方的参数进行设置,需要注意的是第一个按钮的defaultSelected为1: 79 | ```objc 80 | _ninaSelectionView.defaultSelected = 1; 81 | ``` 82 | * 您可以对显示出来的阴影背景进行设置,可以选择不显示阴影背景(需要您注意的是,如果想对阴影的alpha值进行设定,您必须先要将shadowEffect设为**YES**) 83 | ```objc 84 | _ninaSelectionView.shadowEffect = YES; 85 | _ninaSelectionView.shadowAlpha = 0.4; 86 | ``` 87 | * If you wanna change buttons' parameters(column,width,height) or view frame,you can go to UIParameter.h to change them.如果您觉得默认的按钮参数(例如每排数量、高度、宽度)或整体NinaSelectionView的frame并不是您想要的,您可以去UIParameter.h进行设置,里面应该可以满足您的需求,需要注意的是,如果您想改变弹出view的Y值,NinaSelectionView为您提供了**nina_popY**属性,您可以通过设置它来进行调整。 88 | 89 | ## 版本更新说明 90 | #### v0.1.0 91 | 第一个版本提交。 92 | 93 | ## 反馈 94 | * 如果您在使用的过程中遇到任何问题或者建议,希望您issue我或者发邮件至zhaogengda@126.com,帮助我来完善它。 95 | 96 | ## Licence 97 | 98 | This project uses MIT License. 99 | --------------------------------------------------------------------------------