TBActionSheet
TBActionSheet 是一个小型库,允许您用优雅且完全可定制的 actionsheet 替换 Apple 不可定制的 UIActionSheet
,您可以在您的 iOS 应用中使用它。默认风格是 iOS9/10,您可以创建自己的风格。享受!
以下是一些显示 TBActionSheet 强大力量的图片。您可以动态更改 UI
BTW,TBActionSheet
也支持 自定义动画!
🌟 功能
- 标题
- 描述信息
- 在任何地方插入自定义视图
- 自定义动画
- 自定义:字体、颜色、尺寸、角 & 更多
- 按钮或背景按下时的闭包
- 与 UIActionSheet 相似实现
- 使用块语法添加按钮
- 滚动整个 actionsheet
- 在 iOS7 下的模糊效果
- 在 iOS8 下的自动旋转
- CocoaPods
- Carthage
📚 文章
🔮 示例
要运行示例项目,克隆仓库然后运行 MTDemo 目标。
💰 需求
- iOS 7.0+ (iOS 8.0+ 支持完整功能)
- Xcode 10.1+
📲 安装
CocoaPods
CocoaPods 是一个用于 Cocoa 项目的依赖管理器。您可以使用以下命令安装它
$ gem install cocoapods
要使用 CocoaPods 将 TBActionSheet 集成到您的 Xcode 项目中,请在上面的 Podfile
中指定它
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
target 'MyApp' do
pod 'TBActionSheet'
end
您需要将 "MyApp" 替换为您的项目名称。
然后,运行以下命令
$ pod install
Carthage
Carthage是一个去中心化的依赖管理器,构建您的依赖并提供二进制框架。
您可以使用以下命令使用Homebrew安装Carthage:
$ brew update
$ brew install carthage
要使用Carthage将TBActionSheet集成到Xcode项目中,在您的Cartfile
中指定它
github "yulingtianxia/TBActionSheet"
运行carthage update
构建框架,然后将构建的TBActionSheetKit.framework
拖放到您的Xcode项目。
手动操作
只需将“源”文档文件夹拖放到您的项目中。
🐒 用法
TLDR
您可以在TBAlertControllerDemo项目中参考'ViewController.m'。基本用法与'UIActionSheet'相同。
要使TBActionSheet看起来像微信风格,您可以将这些属性设置为TBActionShet
或它的UIAppearance
,如下所示
sheetWidth = MIN(kScreenWidth, kScreenHeight);
backgroundTransparentEnabled = NO;
rectCornerRadius = 0;
更多您需要的
基本用法与UIActionSheet
相同。只需用TBActionSheet
替换UIActionSheet
。如果您想自定义操作表,只需配置一些属性。
GitHub wiki可帮助您掌握高级用法。
还有一个TBActionSheet
的示例项目。
TBAlertController
此仓库还包括 TBAlertController
,它统一了 UIAlertController
、UIAlertView
和 UIActionSheet
。当在 iOS 8.2 及以后的系统中使用时,TBAlertController
会对 UIAlertController
进行调用。反之,则会调用 UIAlertView
或 UIActionSheet
。
TBAlertController
的 API 使用方法与 UIAlertController
类似。我也提供了 TBAlertAction
代替 UIAlertAction
。
以下是一个示例
TBAlertController *controller = [TBAlertController alertControllerWithTitle:@"TBAlertController" message:@"AlertStyle" preferredStyle:TBAlertControllerStyleAlert];
TBAlertAction *clickme = [TBAlertAction actionWithTitle:@"点我" style: TBAlertActionStyleDefault handler:^(TBAlertAction * _Nonnull action) {
NSLog(@"%@",action.title);
}];
TBAlertAction *cancel = [TBAlertAction actionWithTitle:@"取消" style: TBAlertActionStyleCancel handler:^(TBAlertAction * _Nonnull action) {
NSLog(@"%@",action.title);
}];
[controller addAction:clickme];
[controller addAction:cancel];
[self presentViewController:controller animated:YES completion:nil];
有关 TBAlertController
的更多信息,请访问我的博客中的这篇帖子:这里。
❤️ 贡献
- 如果您需要帮助或想提出一般性问题,请打开一个 issue。
- 如果您发现了一个错误,请打开一个 issue。
- 如果您有功能请求,请打开一个 issue。
- 如果您想进行贡献,提交一个 pull request。
👨💻 作者
yulingtianxia, [email protected]
👮♂️ 许可证
TBActionSheet
以 MIT 许可证可用。有关更多信息,请参阅 LICENSE 文件。