-
Notifications
You must be signed in to change notification settings - Fork 0
Home
- MDButton
- MDTextField
- MDTableViewCell
- MDCollectionViewCell
- MDProgress
- MDSlider
- MDSwitch
- MDTabBar
- MDTabBarViewController
- MDSnackbar
- MDToast
- MDDatePickerDialog
- MDTimePickerDialog
Create new instance programmatically or change Custom class name of a UIButton in Interface Builder
| Property Name | Type | Default Value | Note |
|---|---|---|---|
| mdButtonType | MDButtonType | Raised | Button type |
| rippleColor | UIColor | #D6D6D6 | color of ripple effect |
| Attribute Name | Type | Acceptable Value | Note |
|---|---|---|---|
| type | number | 0, 1, 2, 3 | Button type, maps to the Raised, Flat, Floating Action Button & Floating Action Button with rotation animation. Other value maps to Raised Button |
| rippleColor | color | Color of ripple effect | |
| imageNormal | UIImage | Used with type 3: button image for normal state | |
| imageRotated | UIImage | Used with type 3: button image for rotated state (null able) |
- Constructor
- (id)initWithFrame:(CGRect)frame type:(enum MDButtonType)buttonType rippleColor:(UIColor *)rippleColor;
- Create a raised button
MDButton *raisedButton = [[MDButton alloc] initWithFrame:CGRectMake(100, 100, 120, 40) type:MDButtonTypeRaised rippleColor:nil];
- Create a flat button
MDButton *flatButton = [[MDButton alloc] initWithFrame:CGRectMake(100, 200, 120, 140) type:MDButtonTypeFlat rippleColor:nil];
- Create a floating action button
MDButton *floatingButton = [[MDButton alloc] initWithFrame:CGRectMake(110, 300, 100, 100) type:MDButtonTypeFloatingAction rippleColor:[UIColor blueColor]];
- Create a floating action button with rotation animation
MDButton *floatingRotationButton = [[MDButton alloc] initWithFrame:CGRectMake(110, 300, 100, 100) type:MDButtonTypeFloatingActionRotation rippleColor:[UIColor blueColor]];
Create new instance programmatically or change Custom class name of a UIView in Interface Builder. This control only works with Auto Layout.
| Property Name | Type | Default Value | Note |
|---|---|---|---|
| text | NSString | 0 | |
| singleLine | BOOL | NO | |
| fullWidth | BOOL | NO | |
| enabled | BOOL | YES | |
| normalColor | UIColor | #00000042 | |
| highlightColor | UIColor | #3F51B5 | |
| errorColor | UIColor | #FF4081 | |
| disabledColor | UIColor | #00000042 | |
| textColor | UIColor | #000000DD | |
| hintColor | UIColor | #00000042 | |
| labelsFont | UIFont | ||
| inputTextFont | UIFont | ||
| hint | NSString | ||
| label | NSString | not visible if fullWidth is YES | |
| floatingLabel | BOOL | NO | enable floating label or not. If it's YES, hint will not visible |
| highlightLabel | BOOL | NO | highlight label with highlightColor or not |
| errorMessage | NSString | ||
| hasError | BOOL | NO | show errorMessage or not |
| maxCharacterCount | int | 0 | |
| minVisibleLines | int | 0 | |
| maxVisibleLines | int | 0 | |
| secureTextEntry | BOOL | NO | |
| dividerAnimation | BOOL | YES | set hightlight (divider) animation when focus/lost focus |
| delegate | id | nil | |
| autoComplete | BOOL | NO | |
| suggestionsDictionary | NSArray | nil | string array data used in Auto complete mode |
| Attribute Name | Type | Acceptable Value | Note |
|---|---|---|---|
| text | string | ||
| singleLine | boolean | ||
| enabled | boolean | ||
| fullWidth | boolean | ||
| highlightColor | color | ||
| errorColor | color | ||
| disabledColor | color | ||
| textColor | color | ||
| hintColor | color | ||
| normalColor | color | ||
| hint | string | ||
| label | string | ||
| floatingLabel | boolean | ||
| highlightLabel | boolean | ||
| errorMessage | string | ||
| maxCharacterCount | number | ||
| minVisibleLines | number | ||
| maxVisibleLines | number | ||
| secureTextEntry | boolean | ||
| autoComplete | boolean | ||
| dividerAnimation | boolean |
MDTextField *textField = [[MDTextField alloc] initWithFrame:CGRectMake(0, 0, 320, 50)];
textField.delegate = self;
textField.singleLine = true;
textField.maxCharacterCount = 30;
textField.errorMessage = @"Wrong password";
textField.secureTextEntry = true;
textField.label = @"Password";
textField.floatingLabel = true;
[self.view addSubview:textField];
Create new instance programmatically or change Custom class name of a UITableViewCell in Interface Builder
| Property Name | Type | Default Value | Note |
|---|---|---|---|
| rippleColor | UIColor | #D6D6D6 | color of ripple effect |
| Attribute Name | Type | Acceptable Value | Note |
|---|---|---|---|
| rippleColor | color | Color of ripple effect |
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
MDTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:RowIdentifier];
if (cell == nil) {
// Create new MDTableViewCell with default style, or you can subclass it.
cell = [[MDTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:RowIdentifier];
}
cell.textLabel.text = [data objectAtIndex:indexPath.row];
return cell;
}
Create new instance programmatically or change Custom class name of a UICollectionViewCell in Interface Builder
| Property Name | Type | Default Value | Note |
|---|---|---|---|
| rippleColor | UIColor | #D6D6D6 | color of ripple effect |
| Attribute Name | Type | Acceptable Value | Note |
|---|---|---|---|
| rippleColor | color | Color of ripple effect |
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
NSMutableArray *data = [self.dataArray objectAtIndex:indexPath.section];
NSString *cellData = [data objectAtIndex:indexPath.row];
static NSString *cellIdentifier = @"cvCell";
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
UILabel *titleLabel = (UILabel *)[cell viewWithTag:100];
[titleLabel setText:cellData];
return cell;
}
Create new instance programmatically or change Custom class name of a UIView in Interface Builder
| Property Name | Type | Default Value | Note |
|---|---|---|---|
| progressColor | UIColor | #007AFF | |
| trackColor | UIColor | #B4CFEE | |
| trackWidth | float | 5 | |
| progress | float | 0 | only used on Determinate type |
| enableTrackColor | BOOL | NO | |
| progressType | MDProgressType | Indeterminate | type of progress, Indeterminate or Determinate |
| progressStyle | MDProgressStyle | Circular | display style, Circular or Linear |
| Attribute Name | Type | Acceptable Value | Note |
|---|---|---|---|
| progressColor | color | ||
| trackColor | color | ||
| trackWidth | number | ||
| enableTrackColor | boolean | ||
| progress | number | only used on Determinate type | |
| type | number | 0, 1 | Progress type, maps to Indeterminate or Determinate, other value maps to Indeterminate |
| style | number | 0, 1 | Progress style, maps to Circular or Linear, other value maps to Circular |
- Create a determinate progress
MDProgress *determinateProgress = [[MDProgress alloc] init];
[determinateProgress setStyle:Linear];
[determinateProgress setType:Determinate];
determinateProgress.progress = .1f;
Create new instance programmatically or change Custom class name of a UIView in Interface Builder. This control only works with Auto Layout.
| Property Name | Type | Default Value | Note |
|---|---|---|---|
| value | float | 0 | |
| minimumValue | float | 0 | |
| maximumValue | float | 100 | |
| step | float | 0 | tick step for Discrete slider |
| enabled | BOOL | YES | |
| enabledValueLabel | BOOL | NO | |
| precision | NSUInteger | 0 | number of digit after decimal point in floating value label |
| thumbOnColor | UIColor | #3F51B5 | |
| trackOnColor | UIColor | #3F51B5 | |
| thumbOffColor | UIColor | #00000042 | |
| trackOffColor | UIColor | #00000042 | |
| disabledColor | UIColor | #00000021 | |
| tickMarksColor | UIColor | #000000 | |
| leftImage | UIImage | nil | |
| rightImage | UIImage | nil |
| Attribute Name | Type | Acceptable Value | Note |
|---|---|---|---|
| value | number | ||
| minimumValue | number | ||
| maximumValue | number | ||
| step | number | ||
| enabled | boolean | ||
| enabledValueLabel | boolean | ||
| precision | number | >=0 | |
| thumbOnColor | color | ||
| trackOnColor | color | ||
| thumbOffColor | color | ||
| trackOffColor | color | ||
| disabledColor | color | ||
| tickMarksColor | color | ||
| leftImage | image | ||
| rightImage | image |
MDSlider *slider = [[MDSlider alloc] init];
slider.minimumValue = 5;
slider.maximumValue = 50;
slider.step = 5;
slider.enabledValueLabel = YES;
[self.view addSubview:slider];
slider.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:slider attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeading multiplier:1 constant:0]];
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:slider attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTrailing multiplier:1 constant:0]];
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:slider attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1 constant:0]];
Create new instance programmatically or change Custom class name of a UIView in Interface Builder.
| Property Name | Type | Default Value | Note |
|---|---|---|---|
| on | BOOL | NO | |
| thumbOn | UIColor | #3F51B5 | |
| trackOn | UIColor | #3F51B57F | |
| thumbOff | UIColor | #FAFAFA | |
| trackOff | UIColor | #00000042 | |
| thumbDisabled | UIColor | #BDBDBD | |
| trackDisabled | UIColor | #0000001E |
| Attribute Name | Type | Acceptable Value | Note |
|---|---|---|---|
| on | boolean | ||
| thumbOn | color | ||
| trackOn | color | ||
| thumbOff | color | ||
| trackOff | color | ||
| thumbDisabled | color | ||
| trackDisabled | color |
MDSwitch *newSwitch = [[MDSwitch alloc] initWithFrame:CGRectMake(0, 0, 100, 50)];
[self.view addSubview:newSwitch];
Create new instance programmatically or change Custom class name of a UIView in Interface Builder.
| Property Name | Type | Default Value | Note |
|---|---|---|---|
| textColor | UIColor | #FFFFFF | |
| backgroundColor | UIColor | #3F51B5 | |
| indicatorColor | UIColor | #FFFFFF | |
| rippleColor | UIColor | #FFFFFF | |
| textFont | UIFont | ||
| selectedIndex | NSUInteger | 0 | |
| numberOfItems | NSInteger | 0 | |
| delegate | id | nil |
| Attribute Name | Type | Acceptable Value | Note |
|---|---|---|---|
| textColor | color | ||
| backgroundColor | color | ||
| indicatorColor | color | ||
| rippleColor | color |
- (void)setItems:(NSArray *)items;
- (void)insertItem:(id)item atIndex:(NSUInteger)index animated:(BOOL)animated;
- (void)removeItemAtIndex:(NSUInteger)index animated:(BOOL)animated;
- (void)replaceItem:(id)item atIndex:(NSUInteger)index;
- (NSMutableArray *)tabs;
MDTabBar *tabBar = [[MDTabBar alloc] initWithFrame:CGRectMake(0, 200, 320, 100)];
[tabBar setItems:@[ @"TAB ONE", @"THE NEXT TAB" ]];
tabBar.delegate = self;
tabBar.selectedIndex = 1;
[self.view addSubview:tabBar];
Create new instance or make a class extend from MDTabBarViewController programmatically.
| Property Name | Type | Default Value | Note |
|---|---|---|---|
| tabBar | MDTabBar | ||
| delegate | id | ||
| selectedIndex | NSUInteger | 0 |
- Constructor
- (instancetype)initWithDelegate:(id)delegate;
- Public Function
- (void)setItems:(NSArray *)items;
MDTabBarViewController *tabBarViewController = [[MDTabBarViewController alloc] initWithDelegate:self];
NSArray *names = @[@"TAB ONE",@"TAB TWO", @"TAB THREE"];
[tabBarViewController setItems:names];
[self addChildViewController:tabBarViewController];
[self.view addSubview:tabBarViewController.view];
[tabBarViewController didMoveToParentViewController:self];
UIView *controllerView = tabBarViewController.view;
id<UILayoutSupport> rootTopLayoutGuide = self.topLayoutGuide;
id<UILayoutSupport> rootBottomLayoutGuide = self.bottomLayoutGuide;
NSDictionary *viewsDictionary = NSDictionaryOfVariableBindings(rootTopLayoutGuide, rootBottomLayoutGuide, controllerView);
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[rootTopLayoutGuide]["@"controllerView][" @"rootBottomLayoutGuide]" options:0 metrics:nil views:viewsDictionary]];
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[controllerView]|" options:0 metrics:nil views:viewsDictionary]];
Create new instance programmatically.
| Property Name | Type | Default Value | Note |
|---|---|---|---|
| text | NSString | ||
| actionTitle | NSString | title for action button | |
| textColor | UIColor | #FFFFFF | |
| actionTitleColor | UIColor | #FFFFFF | text color for action button |
| duration | double | 2 | duration in seconds |
| swipeable | BOOL | NO | |
| multiline | BOOL | NO | |
| isShowing | BOOL | NO | readonly |
- Constructors
- (instancetype)initWithText:(NSString *)text actionTitle:(NSString *)action;
- (instancetype)initWithText:(NSString *)text actionTitle:(NSString *)action duration:(double)duration;
- Public functions
- (void)show;
- (void)dismiss;
// Add target for action button's TouchUpInside event
- (void)addTarget:(id)target action:(SEL)aSelector;
- (void)addDelegate:(id<MDSnackbarDelegate>)delegate;
- (void)removeDelegate:(id<MDSnackbarDelegate>)delegate;
MDSnackbar *snackbar = [[MDSnackbar alloc] initWithText: @"Connection time out." actionTitle:@"retry"];
snackbar.actionTitleColor = [UIColorHelper colorWithRGBA:@"#4CAF50"];
snackbar.multiline = YES;
[snackbar show];
Create new instance programmatically.
| Property Name | Type | Default Value | Note |
|---|---|---|---|
| text | NSString | ||
| textColor | UIColor | #FFFFFF | |
| textFont | UIFont | ||
| duration | double | 2 | duration in seconds |
| isShowing | BOOL | readonly | |
| gravity | MDGravity | MDGravityBottom | MDGravityCenterHorizontal | The location at which the toast should appear on the screen |
- Constructor
- (instancetype)initWithText:(NSString *)text duration:(double)duration;
- Public functions
- (void)setGravity:(MDGravity)gravity xOffset:(int)xOffset yOffset:(int)yOffset;
- (void)show;
- (void)dismiss;
MDToast *toast = [[MDToast alloc] initWithText:@"Toast message." duration:kMDToastDurationShort];
toast.backgroundColor = [UIColor colorWithRed:0 green:.2f blue:.5f alpha:.8f];
toast.textFont = [UIFont systemFontOfSize:14];
[toast setGravity:MDGravityCenterVertical | MDGravityCenterHorizontal];
[toast show];
Create new instance programmatically.
@protocol MDDatePickerDialogDelegate <NSObject>
- (void)datePickerDialogDidSelectDate:(NSDate *)date;
@end
- (void)show;
MDDatePickerDialog *datePicker = [[MDDatePickerDialog alloc] init];
datePicker.delegate = self;
[datePicker show];
Create new instance programmatically.
@protocol MDTimePickerDialogDelegate <NSObject>
- (void)timePickerDialog:(MDTimePickerDialog *)timePickerDialog
didSelectHour:(NSInteger)hour
andMinute:(NSInteger)minute;
@end
- Constructor
- (instancetype)init;
- (instancetype)initWithHour:(NSInteger)hour andWithMinute:(NSInteger)minute;
- Public Functions
- (void)show;
MDTimePickerDialog *timePicker = [[MDTimePickerDialog alloc] init];
timerPicker.delegate = self;
[timerPicker show];