Skip to content
This repository has been archived by the owner on Apr 1, 2022. It is now read-only.

lifution/FSActionSheet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FSActionSheet

模仿微信底部ActionSheet, 支持横屏显示.(支持iOS6及往后版本)

按钮如果过多则默认显示为屏幕高度的默认比例, 然后按钮支持滑动, 否则不支持滑动按钮.

环境要求:

  • iOS 6 +
  • Xcode 9 +

支持使用cocoapods引入:

pod 'FSActionSheet'

各种样式效果图:

Example screenshot

使用示例:

// 类UIActionSheet初始化绑定代理和设置标题
- (void)show {
	FSActionSheet *actionSheet = [[FSActionSheet alloc] initWithTitle:@"这是ActionSheet的标题" delegate:self cancelButtonTitle:@"关闭" highlightedButtonTitle:@"删除" otherButtonTitles:@[@"拍照", @"从相册选取"]];
	// show
	[actionSheet show];
}
// FSActionSheetDelegate
- (void)FSActionSheet:(FSActionSheet *)actionSheet selectedIndex:(NSInteger)selectedIndex {
    NSLog(@"选择了第[%zi]项", selectedIndex);
}

// 自己组装item设定为actionSheet的按钮
- (void)show {
	NSMutableArray *actionSheetItems = [@[FSActionSheetTitleWithImageItemMake(FSActionSheetTypeNormal, [UIImage imageNamed:@"camera"], @"拍照"),
                                   	      FSActionSheetTitleWithImageItemMake(FSActionSheetTypeNormal, [UIImage imageNamed:@"album"], @"从相册选取"),
                                      	  FSActionSheetTitleWithImageItemMake(FSActionSheetTypeHighlighted, [UIImage imageNamed:@"delete"], @"删除")]
                                    	   mutableCopy];
	FSActionSheet *actionSheet = [[FSActionSheet alloc] initWithTitle:nil cancelTitle:@"关闭" items:actionSheetItems];
	actionSheet.contentAlignment = FSContentAlignmentLeft;
	// 展示并绑定选择回调
	[actionSheet showWithSelectedCompletion:^(NSInteger selectedIndex) {
		FSActionSheetItem *item = actionSheetItems[selectedIndex];		
		_label.text = item.title;
	}];
}

LICENSE

FSActionSheet 基于 MIT 协议开源. 更多开源信息请查看 LICENSE 文件.