Demo Address:
Https://github.com/chenfanfang/CollectionsOfExample
Ffdropdownmenu Frame Address:
Https://github.com/chenfanfang/FFDropDownMenu
As usual, I'll attach two.
Custommenustyle.gif
Custommenustyle.png
#import <FFDropDownMenuBasedModel.h>@interface FFDropDownCustomMenuStyle1Model : FFDropDownMenuBasedModel/** 主标题的背景颜色 */@property (nonatomic, strong) UIColor *mainTitleBgColor;/** 主标题 */@property (nonatomic, copy) NSString *mainTitle;/** 副标题 */@property (nonatomic, copy) NSString *subTitle;//菜单模型创建的属性用于自定义菜单cell,所以需要什么属性,自己定义@end
.m文件
#import "FFDropDownCustomMenuStyle1Model.h"@implementation FFDropDownCustomMenuStyle1Model@end
FFDropDownCustomMenuStyle1Cell.h
#import <FFDropDownMenuView.h>/** * 自定义菜单效果1 菜单 cell */@interface FFDropDownCustomMenuStyle1Cell : FFDropDownMenuBasedCell@end
FFDropDownCustomMenuStyle1Cell.m
#import "FFDropDownCustomMenuStyle1Cell.h"//model#import "FFDropDownCustomMenuStyle1Model.h"@interface FFDropDownCustomMenuStyle1Cell ()@property (weak, nonatomic) IBOutlet UILabel *mainTitle_Label;@property (weak, nonatomic) IBOutlet UILabel *subTitle_Label;@[email protected] FFDropDownCustomMenuStyle1Cell- (void)setMenuModel:(id)menuModel { _menuModel = menuModel; //在这里将模型转成自定义的模型
}@end
cell的xib布局图如下
Snip20160915_1.png
#import "FFDropDownCustomMenuStyle1VC.h"//controller#import "FFDropDownMenuNextPageVC.h"//view#import < Ffdropdownmenuview.h>//model#import "FFDropDownCustomMenuStyle1Model.h" @interface FFDROPDOWNCUSTOMMENUSTYLE1VC ()/** drop-down menu */@property (nonatomic, strong) Ffdropdownmenuview *dropdownmenu;@[email protected] ffdropdowncustommenustyle1vc-(void) viewdidload { [super Viewdidload]; nbsp [self Createdropdownmenu]; [self Setupnav];} -(void) Createdropdownmenu { nsarray *menumodelsarr = [self getdropdownmenumodelsarray];   ; self.dropdownmenu = [Ffdropdownmenuview new]; //animate, you can set your own animation effects according to your project needs self.dropdownmenu.menuanimatetype = Ffdropdownmenuviewanimatetype_fallfromtop; //If a gray transparent mask is not required, the following two opacity can be set to 0 Self.dropDownMenu.bgColorbeginAlpha = 0; self.dropdownmenu.bgcolorendalpha = 0; //Sets the width of the drop-down menu to the width of the entire screen self.dropDownMenu.menuWidth = [UIScreen mainscreen]. Bounds.size.width; //settings menu The margin on the right side of the screen is 0 Self.dropDownMenu.menuRightMargin = 0; //cancel menu fillet effect Self.dropDownMenu.menuCornerRadius = 0; //hidden triangles self.dropDownMenu.triangleSize = Cgsizezero; self.dropdownmenu.eachmenuitemheight = 70; self.dropdownmenu.menumodelsarray = Menumodelsarr; self.dropdownmenu.cellclassname = @ "Ffdropdowncustommenustyle1cell.xib"; self.dropdownmenu.menuitembackgroundcolor = Ffcolor (255, 255, 255, 0.7); [self.dropdownmenu setup]; }/** Get drop-down menu model array */-(Nsarray *) Getdropdownmenumodelsarray { __weak typeof (self) weakself = self ; &NBSP; ffdropdowncustommenustyle1model *menumodel1 = [Ffdropdowncustommenustyle1model new]; menumodel1.maintitlebgcolor = Ffcolor (54, 188, 37, 1); menumodel1.maintitle = @ "1"; menumodel1.subtitle = @ "first menu Item"; menumodel1.menublock = ^ { &NBSP;FFDROPDOWNM ENUNEXTPAGEVC *VC = [FFDROPDOWNMENUNEXTPAGEVC new]; vc.navigationitem.title = @ "first menu Item"; [weakself.navigationcontroller PUSHVIEWCONTROLLER:VC animated: YES]; }; ffdropdowncustommenustyle1model *menumodel2 = [Ffdropdowncustommenustyle1model new]; menumodel2.maintitlebgcolor = Ffcolor (255, 199, 40, 1); menumodel2.maintitle = @ "2"; menumodel2.subtitle = @ "Second menu Item"; menumodel2.menublock = ^ { &NBSP;FFDROPDOWNM ENUNEXTPAGEVC *VC = [FFDROPDOWNMENUNEXTPAGEVC new]; vc.navigationitem.title = @ "Second menu Item"; [weakself.navigationcontroller PUSHVIEWCONTROLLER:VC animated: YES]; }; ffdropdowncustommenustyle1model *menumodel3 = [Ffdropdowncustommenustyle1model new]; menumodel3.maintitlebgcolor = Ffcolor (255, 81, 31, 1); menumodel3.maintitle = @ "3"; menumodel3.subtitle = @ "third menu Item"; menumodel3.menublock = ^ { &NBSP;FFDROPDOWNMENUNEXTPAGEVC *VC = [FFDROPDOWNMENUNEXTPAGEVC new]; vc.navigationitem.title = @ "Facebook"; [weakself.navigationcontroller PUSHVIEWCONTROLLER:VC animated: YES]; }; ffdropdowncustommenustyle1model *menumodel4 = [Ffdropdowncustommenustyle1model new]; menumodel4.maintitlebgcolor = Ffcolor (18, 170, 158, 1); menumodel4.maintitle = @ "4"; menumodel4.subtitle = @ "Fourth menu Item"; menumodel4.menublock = ^ { &NBSP;FFDROPDOWNMENUNEXTPAGEVC *VC = [FFDROPDOWNMENUNEXTPAGEVC new]; vc.navigationitem.title = @ "Facebook"; [weakself.navigationcontroller PUSHVIEWCONTROLLER:VC animated: YES]; }; ffdropdowncustommenustyle1model *menumodel5 = [Ffdropdowncustommenustyle1model new]; menumodel5.maintitlebgcolor = Ffcolor (0, 119, 195, 1); menumodel5.maintitle = @ "5"; menumodel5.subtitle = @ "fifth menu Item"; menumodel5.menublock = ^ { &NBSP;FFDROPDOWNM ENUNEXTPAGEVC *VC = [FFDROPDOWNMENUNEXTPAGEVC new]; vc.navigationitem.title = @ "Facebook"; [weakself.navigationcontroller PUSHVIEWCONTROLLER:VC animated: YES]; }; nsarray *menumodelarr = @[menumodel1,menumodel2,menumodel3,menumodel4,menumodel5]; return Menumodelarr; }/** Initialize navigation bar */-(void) Setupnav { self.navigationitem.rightbarbuttonitEM = [[Uibarbuttonitem alloc] Initwithbarbuttonsystemitem:uibarbuttonsystemitemadd target:self.dropDownMenu action:@ Selector (ShowMenu)]; self.navigationitem.title = @ "Combat: Custom Menu Effect 1"; } @end
IOS drop-down menu Ffdropdownmenu custom drop-down menu style combat-B