Skip to content
This repository has been archived by the owner on Nov 10, 2021. It is now read-only.

immago/DBFlatPicker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DBFlatPicker

podver platform license

Flat picker for iOS written on Objective-C. It's UIView with UITableView inside, with behavior of UIPickerView.

dbflatpicker

Installation

CocoaPods

pod 'DBFlatPicker'

Manual

Copy DBFlatPickerView.h, DBFlatPickerView.m and DBFlatPickerView.xib from Classes directory to your project.

Usage

// Uncomment if picker not created in storyboard
// self.picker = [[DBFlatPickerView alloc]initWithFrame:CGRectMake(0, 0, 300, 200)];
self.picker.data = @[@"item 1", @"item 2", @"item 3", @"item 4"];
self.picker.delegate = self;
[self.picker selectRow:2];

...

- (void)flatPickerView:(DBFlatPickerView*)flatPickerView didSelectRow:(NSInteger)row {
NSLog(@"selected row = %ld", (long)row);
}

- (void)labelStyleForFlatPickerView:(DBFlatPickerView*)flatPickerView forLabel:(UILabel*)label {
label.textColor = [UIColor blackColor];
label.font = [UIFont systemFontOfSize:20];
}

Properties

NSArray <NSString*> *data - Array of displayed NSString
CGFloat paddingLeft - Left margin of label
CGFloat paddingRight - Right margin of label
CGFloat rowHeight - Height of rows
UIColor *selectionColor - Color of selection overlay (use colors with transparency)

Delegates

/// Called when picker end row selection
- (void)flatPickerView:(DBFlatPickerView*)pickerView didSelectRow:(NSInteger)row;

/// Apply style to label
- (void)labelStyleForFlatPickerView:(DBFlatPickerView*)pickerView forLabel:(UILabel*)label;