
##FCPopMenu 简易、友好的下拉菜单
An easy,friendly and customizable way to make a popover menu.

###Installation
Cocoapods
pod “FCPopMenu”, “~>1.0”
Use pod repo update if not exist.
Manual
Download FCPopMenu,drag folder “FCPopMenu” into your project, make sure to ues “create group if need”.
###Useage
How to create FCPopMenuItems
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
NSArray *[email protected][@"新建剧情",@"发布招募",@"搜一搜"]; NSArray *[email protected][@"sence_new",@"recruit_new",@"sence_search"]; NSMutableArray *items=[NSMutableArray array]; __weak typeof(self) wkself=self; for(int i=0;i<names.count;i++){
FCPopMenuItem *item=[FCPopMenuItem itemWithImage:[UIImage imageNamed:imgs[i]] title:names[i] titleColor:[UIColor whiteColor] handler:^(FCPopMenuItem *sender) {
[wkself listClickAction:sender]; }]; [items addObject:item]; }
|
FCPopMenu
Create a popover menu like this
1 2 3 4 5
|
_list=[FCPopMenu menuWithFrame:CGRectMake(kFCPopMenuWidth-143, 64, 138, 140) trangleHeight:10 tranglePosition:CGPointMake(112, 0) items:items]; _list.mainColor=[UIColor colorWithRed:73/255.f green:73/255.f blue:73/255.f alpha:1.f]; _list.rowHeight=43.5; _list.sperateColor=[UIColor colorWithRed:217/255.f green:217/255.f blue:217/255.f alpha:1.f]; _list.seperateInsets=UIEdgeInsetsMake(0, 14, 0, 14);
|
You may need a overlay view
1 2 3 4 5 6 7 8 9 10
|
-(UIControl *)back{
if(!_back){
_back=[[UIControl alloc] initWithFrame:self.view.bounds]; _back.backgroundColor=[UIColor clearColor]; [_back addTarget:self action:@selector(hideList:) forControlEvents:UIControlEventTouchUpInside]; } return _back; }
|
Troggle show/close menu
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
-(void)addBtnClickAction:(UIBarButtonItem *)sender{
sender.enabled=NO; if(self.list.superview){
[self hideList:self.back]; sender.enabled=YES; return; } [self.view addSubview:self.back]; [self.view addSubview:self.list]; self.list.alpha=0.0; __weak typeof(self) wkself=self; [self.list mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(wkself.view).offset(-5); make.top.equalTo(wkself.view).offset(64); make.size.mas_equalTo(CGSizeMake(138, 140)); }]; [UIView animateWithDuration:0.3 animations:^{
wkself.list.alpha=1.0; }]; sender.enabled=YES; }
|
Monitor click action
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
-(void)listClickAction:(FCPopMenuItem *)sender{
[self hideList:self.back]; NSString *title=[sender.title copy]; if([title isEqualToString:@"新建剧情"]){
}else if([title isEqualToString:@"发布招募"]){
}else{
} NSLog(@"%@",sender.title); }
|
Hide
1 2 3 4 5
|
-(void)hideList:(UIControl *)sender{
[sender removeFromSuperview]; [self.list removeFromSuperview]; }
|
Source code on github click-> here
About Me
@CGPoitZero

近期评论