Coder Social home page Coder Social logo

yulingtianxia / tbactionsheet Goto Github PK

View Code? Open in Web Editor NEW
950.0 23.0 94.0 45.42 MB

A Custom&Powerful Action Sheet For iOS. 一个 ActionSheet 满足所有样式!超高自由度的可定制!

License: MIT License

Objective-C 97.32% Ruby 1.20% C 1.48%
actionsheet carthage ios ios-ui ios-thirdparty wechat qq cocoapods autorotation objective-c

tbactionsheet's Introduction

TBActionSheet

CI Status Version Carthage compatible License Platform CocoaPods CocoaPods Twitter Follow

TBActionSheet

TBActionSheet is a small library that allows you to substitute Apple's uncustomizable UIActionSheet, with a beautiful and totally customizable actionsheet that you can use in your iOS app. The default style is iOS9/10, you can make your own style. Enjoy!

Here are some pictures showing TBActionSheet's powerful individuation. You can change UI dynamically:

BTW, TBActionSheet also supports CUSTOM ANIMATION!

🌟 Feature

  • Title
  • Description message
  • Insert a custom view at anywhere
  • Custom animation.
  • Customizations: fonts, colors, dimensions, corners & more
  • Closure when a button or background is pressed
  • Similar implementation to UIActionSheet
  • Add button using block syntax
  • Scroll the whole action sheet.
  • Blur Effect under iOS7
  • Autorotation under iOS8
  • CocoaPods
  • Carthage

📚 Article

🔮 Example

To run the example project, clone the repo and run MTDemo target.

💰 Requirement

  • iOS 7.0+ (iOS 8.0+ full features supported)
  • Xcode 10.1+

📲 Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate TBActionSheet into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
target 'MyApp' do
	pod 'TBActionSheet'
end

You need replace "MyApp" with your project's name.

Then, run the following command:

$ pod install

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate TBActionSheet into your Xcode project using Carthage, specify it in your Cartfile:

github "yulingtianxia/TBActionSheet"

Run carthage update to build the framework and drag the built TBActionSheetKit.framework into your Xcode project.

Manual

Just drag the "Source" document folder into your project.

🐒 Usage

TLDR

You can refer to 'ViewController.m' in the TBAlertControllerDemo project.The base usage is same as 'UIActionSheet'.

To let TBActionSheet looks like WeChat style, you can set these properties of TBActionShet or it's UIAppearance like this :

sheetWidth = MIN(kScreenWidth, kScreenHeight);
backgroundTransparentEnabled = NO;
rectCornerRadius = 0;

More than what you want

The base usage is same to UIActionSheet. You can just replace UIActionSheet with TBActionSheet. If you want to customize your action sheet, just configure some properties.

GitHub wiki can help you master advanced usage.

There is also an example project for TBActionSheet.

TBAlertController

This repo also include TBAlertController, which unifies UIAlertController, UIAlertView, and UIActionSheet. TBAlertController will use UIAlertController on iOS 8.2 and later. On the contrary, it will use UIAlertView or UIActionSheet.

The API Usage of TBAlertController is similar to UIAlertController. I also provide TBAlertAction instead of UIAlertAction.

There is an example:

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];

For more infomation about TBAlertController, please visit this post of my blog.

❤️ Contributed

  • If you need help or you'd like to ask a general question, open an issue.
  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

👨🏻‍💻 Author

yulingtianxia, [email protected]

👮🏻 License

TBActionSheet is available under the MIT license. See the LICENSE file for more info.

tbactionsheet's People

Contributors

readmecritic avatar skyline75489 avatar xdream86 avatar yulingtianxia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tbactionsheet's Issues

Crash when snapshot

Code:

- (UIImage *)screenShotRect:(CGRect)aRect
// Use this method to render a snapshot of the view hierarchy into the current context. 
Returns NO if the snapshot is missing image data, YES if the snapshot is complete.
 Calling this method from layoutSubviews while the current transaction is committing 
will capture what is currently displayed regardless if afterUpdates is YES.
- (BOOL)drawViewHierarchyInRect:(CGRect)rect afterScreenUpdates:(BOOL)afterUpdates NS_AVAILABLE_IOS(7_0);

如果在截图的过程中,视图层级中的某个view被释放掉,这个方法可能会导致崩溃
目前仅在iOS 11.0 (15A5318g)上遇到过2次,希望能尽快修复!

issues on stackoverflow

Alert show in view

能否支持把 Alert 放在 view / window 上?

目前有这样的场景:

当 A (自定义的view 添加在 window 上) 弹出,再调用 TBAlertController ,会被 A 给挡住。

destructiveButton位置

兄弟,这个destructiveButton的位置不可以调吗,这样体验很不好啊,删除一般不会放在第一个啊

你这个库在iOS8 下面出现这种错误

dyld: Symbol not found: _NSArray0
Referenced from: /private/var/mobile/Containers/Bundle/Application/4C8312C8-9F92-4B31-9CC8-4217A04AB036/ContactLive.app/Frameworks/TBActionSheetKit.framework/TBActionSheetKit (which was built for iOS 9.3)
Expected in: /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
in /private/var/mobile/Containers/Bundle/Application/4C8312C8-9F92-4B31-9CC8-4217A04AB036/ContactLive.app/Frameworks/TBActionSheetKit.framework/TBActionSheetKit

建议增加对TBAlertController的说明.

首先非常谢谢作者的分享.
不过有一点点小建议.整个readme的说明基本上针对TBActionSheet的,我是自己在对应头文件看api使用TBAlertController .
而去读你的博客又相对没那么"快".

Dismiss actionsheet from custom view

I want to add button in custom view and then on that button click, dismiss the action sheet.
I tried hard but no progress 👎 please if you can help me with it. Thankyou

横屏引起崩溃.

友盟提示是:
Supported orientations has no common orientation with the application, and [MVRewardViewController shouldAutorotate] is returning YES
(null)

然后定位代码,是我调用了TBAlertController去 present 引起的.
因为还牵扯到一个第三方的视频广告 SDK, 我这里不知道该怎么配合排查问题?
看看到底是 TBActionSheet 还是我自己哪里的问题.

内存泄露

我测试TBAlertController时候

出现了内存泄露,检测工具MLeaksFinder
请看86~97行
https://github.com/yulingtianxia/TBActionSheet/blob/master/Example/TBAlertControllerDemo/ViewController.m
下面贴出代码

    TBAlertController *controller = [TBAlertController alertControllerWithTitle:@"TBAlertController" message:@"AlertStyle" preferredStyle:TBAlertControllerStyleActionSheet];
    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];

simulator screen shot 2016 8 24 6 27 36

TBActionSheet 消失之后,创建的window没有销毁

TBActionSheet 消失之后,创建的window没有销毁,导致一些其他第三的loading 无法显示,应该在- (void)close和- (void)buttonTapped:(TBActionButton *)sender中 添加下面标注的一行代码
self.window.rootViewController = nil;
self.window = nil;//(应该添加的)
[self.previousKeyWindow makeKeyAndVisible];

圆角设置问题

矩形圆角设置header和custom同时设置,能否支持自定义目前微信新版的样式呢。。

循环引用和闪屏问题 retain cycle & screenshot blinking

  1. UIImage *(^cutOriginalBackgroundImageInRect)(CGRect frame) 会引起TBBlurEffectBlock被添加到self.blurBlocks后引起循环引用

  2. [view drawViewHierarchyInRect:self.bounds afterScreenUpdates:YES]; 会造成截屏时出现闪屏现象,建议改成 afterScreenUpdates:NO

TBAlertController主动dismiss

建议TBAlertController重写以下方法来主动dismiss,通过adaptiveAlert的话还得使用者来兼容iOS7。
- (void)dismissViewControllerAnimated: (BOOL)flag completion: (void (^ __nullable)(void))completion

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.