Recently wrote this framework: FFDropDownMenu, similar to mobile QQ dropdown menu. Github address: github.com/chenfanfang…

More use methods of demo address: github.com/chenfanfang…

More use of blog: www.jianshu.com/notebooks/5…

First look at the renderings:




Imitation mobile QQ dropdown menu. GIF




Fake mobile QQ dropdown menu. PNG

Installation【 Installation 】

From CocoaPods

pod  FFDropDownMenuCopy the code

Manually import

  • Drag all source files under floder FFDropDownMenu to your project.

  • The files in the FFDropDownMenu folder are

FFDropDownMenuBasedCell.h        FFDropDownMenuBasedCell.m
FFDropDownMenuBasedModel.h       FFDropDownMenuBasedModel.m
FFDropDownMenuCell.h             FFDropDownMenuCell.m
FFDropDownMenuModel.h            FFDropDownMenuModel.m
FFDropDownMenuTriangleView.h     FFDropDownMenuTriangleView.m
FFDropDownMenuView.h             FFDropDownMenuView.mCopy the code

Basic Usage 【 Basic Usage 】

Import the header file first

#import "ffdropdownMenuView.h"Copy the code

Create a strong drop-down menu property

/** dropDownMenu */ @property (nonatomic, strong) FFDropDownMenuView *dropDownMenu;Copy the code

Create menu model array

// ffdropdownMenuModel.h /** * Quickly instantiate a drop-down menu model ** @param menuItemTitle Specifies the title of the menu option * @param menuItemIconName specifies the icon name of the menu option * @ param menuBlock click callback block * * * / + @ the menu of return instantiation model (instancetype) ff_DropDownMenuModelWithMenuItemTitle: (nsstrings *)menuItemTitle menuItemIconName:(NSString *)menuItemIconName menuBlock:(FFMenuBlock)menuBlock;Copy the code
/ * * * / - obtain a drop-down menu model array (NSArray *) getDropDownMenuModelsArray {__weak typeof (self) weakSelf = self; / / the menu model 0 FFDropDownMenuModel * menuModel0 = [FFDropDownMenuModel ff_DropDownMenuModelWithMenuItemTitle: @ "Twitter" menuItemIconName:@"menu0" menuBlock:^{ UIViewController *vc = [UIViewController new];  [weakSelf.navigationController pushViewController:vc animated:YES]; }]; / / the menu model 1 FFDropDownMenuModel * menuModel1 = [FFDropDownMenuModel ff_DropDownMenuModelWithMenuItemTitle: @ "Line" menuItemIconName:@"menu1" menuBlock:^{ //Do Something }]; / / the menu model 2 FFDropDownMenuModel * menuModel2 = [FFDropDownMenuModel ff_DropDownMenuModelWithMenuItemTitle: @ "QQ" menuItemIconName:@"menu2" menuBlock:^{ //Do Something }]; / / the menu model 3 FFDropDownMenuModel * menuModel3 = [FFDropDownMenuModel ff_DropDownMenuModelWithMenuItemTitle: @ "QZone" menuItemIconName:@"menu3" menuBlock:^{ //Do Something }]; // Menu model 4 //................... NSArray *menuModelArr = @[menuModel0, menuModel1, menuModel2, menuModel3......] ; return menuModelArr; }Copy the code

Create a drop-down menu 1

/ * * 1 * / - create a drop-down menu way (void) createDropdownMenuMethodOne {/ / if use CGFloat value by default Please use the FFDefaultFloat / / if use CGSize value by default Please use the FFDefaultSize // To use the default Cell value use FFDefaultCell // to use the default Color value use FFDefaultColor // To use the default ScaleType value use FFDefaultMenuScaleType NSArray *menuModelsArr = [self getDropDownMenuModelsArray]; self.dropDownMenu = [FFDropDownMenuView ff_DefaultStyleDropDownMenuWithMenuModelsArray:menuModelsArr menuWidth:145 eachItemHeight:40 menuRightMargin:10 triangleRightMargin:20]; // If you need to assign additional attributes, you can assign additional attributes, and finally call the setup method. The following / * self. DropDownMenu. MenuScaleType = FFDropDownMenuViewScaleType_TopRight; self.dropDownMenu...... =... ; [self.dropDownMenu setup]; * /}Copy the code

Create a drop-down menu 2

/ 2 * * * create a drop-down menu way / - (void) createDropdownMenuMethodTwo {NSArray * menuModelsArr = [self getDropDownMenuModelsArray]; self.dropDownMenu = [FFDropDownMenuView new]; // To use the default CGFloat value use FFDefaultFloat, or no assignment // to use the default CGSize value use FFDefaultSize, or no assignment // to use the default Cell value use // Use FFDefaultColor if default value is used, or use FFDefaultMenuScaleType if default value ScaleType is used And need not be assigned or / * * * / self drop-down menu model array dropDownMenu. MenuModelsArray = menuModelsArr; / * * the name of the class of the cell * / self. DropDownMenu. CellClassName = FFDefaultCell; / * * the width of the menu (if not set, the default is 150). * / self dropDownMenu. MenuWidth = 145; / * * menu radius (if not set, the default value is 5) * / self. DropDownMenu. MenuCornerRadius = FFDefaultFloat; / * * the height of each option (if not set, the default is 40) * / self. DropDownMenu. EachMenuItemHeight = 40; / * * from the right of the screen menu bar spacing (if not set, the default is 10) * / self dropDownMenu. MenuRightMargin = 10; / * * triangle colors (if not set, the default is white) * / self dropDownMenu. TriangleColor = [UIColor whiteColor]; / * * relative to the triangle keyWindow y value, also is the y value relative to the top of the screen (if not set, the default is 64). * / self dropDownMenu. TriangleY = FFDefaultFloat; / * * triangle distance spacing of the right of the screen (if not set, the default is 20) * / self. DropDownMenu. TriangleRightMargin = FFDefaultFloat; Size. width: indicates the length of the bottom side of the triangle, size.Height: indicates the Height of the triangle. The default for CGSizeMake (15, 10)) * / self. DropDownMenu. TriangleSize = FFDefaultSize; / * * at the beginning of the background color transparency (haven't show the transparency of the menu) (if not set, the default value is 0.02) * / self dropDownMenu. BgColorbeginAlpha = 0; / * * the end of the background color transparency (menu display completely transparent) (if not set, the default value is 0.2) * / self dropDownMenu. BgColorEndAlpha = 0.4; / * * animation time (if not set, the default value is 0.2) * / self dropDownMenu. AnimateDuration = FFDefaultFloat; / * * the telescopic type of menu * / self. DropDownMenu. MenuScaleType = FFDefaultMenuScaleType; Setup [self.dropDownMenu setup]; }Copy the code

According to the menu

    [self.dropDownMenu showMenu];Copy the code

Looking forward to

  • If you encounter a BUG in the process of use, I hope you can write to me in Jane book, or comment on my Jane book blog. Thank you (or try downloading the latest framework code to see if there are any BUG fixes)
  • If you find that the function is not enough in the process of using it, I hope you can write me a message in Jane book, or comment on my blog about Jane book. I really want to add more useful features to this framework, thank you
  • If you would like to work with me to improve FFDropDownMenu, please Pull Requests me

I

www.jianshu.com/users/80fad…