一个 iOS 直接 UITableView, UICollectionView, UIScrollView 父类 分类,用于在顶部显示可定制的悬浮按钮。
要运行示例项目,请克隆仓库,然后首先从 Example 目录运行 pod install
。
需要 iOS SDK 版本 > 8.0
简单地将 /Pod/Classes/
文件夹中的 UIScrollView+FloatingButton.h
和 UIScrollView+FloatingButton.m
包含到您的 App 的 Xcode 项目中。
#import "UIScrollView+FloatingButton.h"
添加数据源和代理方法。
@interface ViewController () <MEVFloatingButtonDelegate>
#pragma mark - MEScrollToTopDelegate Methods
- (void)floatingButton:(UIScrollView *)scrollView didTapButton:(UIButton *)button;
- (void)floatingButtonWillAppear:(UIScrollView *)scrollView;
- (void)floatingButtonDidAppear:(UIScrollView *)scrollView;
- (void)floatingButtonWillDisappear:(UIScrollView *)scrollView;
- (void)floatingButtonDidDisappear:(UIScrollView *)scrollView;
创建一个 MEVFloatingButton
对象。
MEVFloatingButton *button = [[MEVFloatingButton alloc] init];
button.animationType = MEVFloatingButtonAnimationFromBottom;
button.displayMode = MEVFloatingButtonDisplayModeWhenScrolling;
button.position = MEVFloatingButtonPositionBottomCenter;
button.image = [UIImage imageNamed:@"Icon0"];
button.imageColor = [UIColor groupTableViewBackgroundColor];
button.backgroundColor = [UIColor darkGrayColor];
button.outlineColor = [UIColor darkGrayColor];
button.outlineWidth = 0.0f;
button.imagePadding = 20.0f;
button.horizontalOffset = 20.0f;
button.verticalOffset = -30.0f;
button.rounded = YES;
button.hideWhenScrollToTop = YES;
将对象设置为您의 UIScrollView/UITableView/UICollectionView。
[self.tableView setFloatingButtonView:button];
设置委托。
[self.tableView setFloatingButtonDelegate:self]
更多详细信息请查看 示例 项目。一切都在那里。
查看 Changelog.md
Manuel Escrig Ventura, @manuelescrig
图标由Elegant Themes在www.flaticon.com制作
MEVFloatingButton遵循MIT许可证。有关更多信息,请参阅LICENSE文件。