Provide a selectable list show and hide with animation
- Download the zip and copy the folder
KMSelectionView
into your project - In your project:
- Use default options:
KMSelectionView *view =
[[KMSelectionView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 0)
type:KMSelectionViewTypeDefault
titles:@[@"row 1", @"row 2", @"row 3"]
options:nil];
Default style looks like:
-
Change basic options:
NSDictionary *options = @{KMSV_Selected_image: [UIImage imageNamed:@"image_selected"], KMSV_Unselected_image: [UIImage imageNamed:@"image_unselected"], KMSV_Text_alignment: @(NSTextAlignmentCenter)}; KMSelectionView *view = [[KMSelectionView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 0) type:KMSelectionViewTypeDefault titles:@[@"row 1", @"row 2", @"row 3"] options:options]; // or use these method instead - (void)setSelectedImage:(UIImage *)selectedImage unselectedImage:(UIImage *)unselectedImage; - (void)setCellTextAlignment:(NSTextAlignment)alignment;
-
Customized your own cell by setting
view.datasource
to your view controller or anything else, conform to the protocols ofUITableViewDelegate
andUITableViewDatasource
. Return the cell you want to, and all finished.KMSelectionView *view = [[KMSelectionView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 0) type:KMSelectionViewTypeCustomCell titles:@[@"row 1", @"row 2", @"row 3"] options:options]; view.datasource = (id<UITableViewDataSource, UITableViewDelegate>)self;
-
To show the view, using
- (void)doAnimationToPoint:(CGPoint)to inView:(UIView *)view fromDirection:(KMDirection)direction;
-
Set delegate of selection view, for capturing click actions:
- (void)KMSelectionView:(KMSelectionView *)view didSelectIndex:(NSInteger)index { NSLog(@"select line %ld", index); } - (void)KMSelectionViewDidCancel:(KMSelectionView *)view { NSLog(@"cancel"); }
If you define custom cells, then write your code in UITableView's delegate.
Any further ideas or bugs, please open an issue or pull a request
All the source code is under the MIT Licence, please see the LICENCE file for details.