测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可 | MIT |
发布最新版本 | 2017年2月 |
SwiftSwift版本 | 3.0 |
SPM支持SPM | ✗ |
由Lee Sun-hyoup维护。
iOS的简单浮动按钮
要在您的应用中手动安装KCFloatingActionButton,只需将KCFloatingActionButton/*.swift
文件拖放到您的项目中。
KCFABManager.defaultInstance().getButton().addItem(title: "Hello, World!")
KCFABManager.defaultInstance().show()
[[[KCFABManager defaultInstance] getButton] addItemWithTitle:@"Hello, world!"];
[[KCFABManager defaultInstance] show:true];
let fab = KCFloatingActionButton()
fab.addItem(title: "Hello, World!")
self.view.addSubview(fab)
KCFloatingActionButton *fab = [[KCFloatingActionButton alloc] init];
[fab addItemWithTitle:@"Hello, World!"];
[self.view addSubview:fab];
let fab = KCFloatingActionButton()
fab.addItem("Hello, World!", icon: UIImage(named: "icon")!)
self.view.addSubview(fab)
KCFloatingActionButton *fab = [[KCFloatingActionButton alloc] init];
[fab addItem:@"Hello, World" icon:[UIImage imageNamed:@"icon"]];
[self.view addSubview:fab];
let fab = KCFloatingActionButton()
fab.addItem("I got a handler", icon: UIImage(named: "icon")!, handler: { item in
let alert = UIAlertController(title: "Hey", message: "I'm hungry...", preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "Me too", style: .Default, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
fab.close()
})
self.view.addSubview(fab)
KCFloatingActionButton *fab = [[KCFloatingActionButton alloc] init];
__weak KCFloatingActionButton *_fab = fab;
[fab addItem:@"I got a handler" icon:[UIImage imageNamed:@"icon"] handler:^(KCFloatingActionButtonItem *item) {
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Hey" message:@"I'm hungry..." preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"Me too" style:UIAlertActionStyleDefault handler:nil]];
[self presentViewController:alert animated:true completion:nil];
[_fab close];
}];
[self.view addSubview:fab];
let item = KCFloatingActionButtonItem()
item.buttonColor = UIColor.blueColor()
item.title = "Custom item"
KCFABManager.defaultInstance().getButton().addItem(item: item)
KCFloatingActionButtonItem *item = [[KCFloatingActionButtonItem alloc] init];
item.buttonColor = [UIColor blueColor];
item.title = @"Custom item";
[[[KCFABManager defaultInstance] getButton] addItemWithItem:item];
您可以使用 sticky
属性。
fab.sticky = true // sticking to parent UIScrollView(also UITableView, UICollectionView)
scrollView.addSubview(fab)
弹出 | 淡入淡出 | 从左滑入 |
---|---|---|
![]() | ![]() | ![]() |
从上滑入 | 无 | |
![]() | ![]() |
MIT 许可证 (MIT)
版权所有 © 2015 李奂普
特此授予任何获得本软件及其相关文档副本(统称为“软件”)的人,免费无限制地处理该软件的权利,包括但不限于使用、复制、修改、合并、发布、分发、再许可及/或出售副本的权利,并允许有权获得软件的人这样做,前提是必须遵守以下条件
所有副本或软件的大部分都必须包括上述版权声明和本许可声明。
软件按“现状”提供,不提供任何形式的保证,明示或暗示,包括但不限于适销性、适用于特定目的和无侵权性保证。在任何情况下,作者或版权所有者不对任何索赔、损害或其他责任(无论因合同、侵权或其他原因而引起)承担责任,即使事先已被告知此类索赔、损害或其他可能发生。