close
当前位置: 物联网在线 > 技术文库 > ios >

iOS开源:FFToast - GitHub 中最强大的 Notification 和 AlertView 框架

A very powerful iOS message notifications and AlertView extensions. It can be easily realized from the top of the screen, the bottom of the screen and the middle of the screen pops up a notification. You can easily customize the pop-up View.

iOS开源:FFToast - GitHub 中最强大的 Notification 和 AlertView 框架

iOS开源:FFToast - GitHub 中最强大的 Notification 和 AlertView 框架

English instructions Requirements

Requires iOS 8 or later

Requires Automatic Reference Counting (ARC)

Features

Easy to use

Can be easily customized

Installation CocoaPods

To install FFToast using CocoaPods, please integrate it in your existing Podfile, or create a new Podfile:

target 'MyApp' do pod 'FFToast' end

Then run pod install .

Manual

Add FFToast folder to your project

Usage #import <FFToast/FFToast.h>

You can create a message notification that shows the default effect at the top by calling the following method:

/** Create and display one Toast @param title Message title @param message Message content @param iconImage Message icon, when toastType is not FFToastTypeDefault iconImage is empty will still have the corresponding icon @param duration Show duration */ + (void)showToastWithTitle:(NSString *)title message:(NSString *)message iconImage:(UIImage*)iconImage duration:(NSTimeInterval)duration toastType:(FFToastType)toastType;

Where toastType:

typedef NS_ENUM(NSInteger, FFToastType) { //Gray background, no icon FFToastTypeDefault = 0, //Green background + success icon FFToastTypeSuccess = 1, //Red background + error icon FFToastTypeError = 2, //Orange background + warning icon FFToastTypeWarning = 3, //Gray blue background + info icon FFToastTypeInfo = 4, };

for example:

[FFToast showToastWithTitle:@"This is the title" message:@"Message content......." iconImage:[UIImage imageNamed:@"test"] duration:3 toastType:FFToastTypeDefault];

Title (title), message (message), icon (iconImage) can be empty, FFToast will be based on specific content to adapt.

If you want to show the message below the status bar, the bottom of the screen or the middle of the screen, you can set some properties to achieve. Set the display position:

typedef NS_ENUM(NSInteger, FFToastPosition) { //Displayed at the top of the screen FFToastPositionDefault = 0, //Is displayed below the status bar FFToastPositionBelowStatusBar = 1, //Displayed below the status bar + rounded corners + left and right margins FFToastPositionBelowStatusBarWithFillet = 2, //Displayed at the bottom of the screen FFToastPositionBottom = 3, //Displayed at the bottom of the screen + fillet FFToastPositionBottomWithFillet = 4, //Displayed in the middle of the screen FFToastPositionCentre = 5, //Displayed in the middle of the screen + fillet FFToastPositionCentreWithFillet = 6 };

Some other attributes:

//background color @property (strong, nonatomic) UIColor* toastBackgroundColor; //Toast title text color @property (strong, nonatomic) UIColor* titleTextColor; //Toast content text color @property (strong, nonatomic) UIColor* messageTextColor; //Toast title text font @property (strong, nonatomic) UIFont* titleFont; //Toast text font @property (strong, nonatomic) UIFont* messageFont; //Toast View fillet @property(assign,nonatomic)CGFloat toastCornerRadius; //Toast View Transparency @property(assign,nonatomic)CGFloat toastAlpha; //Toast shows the length of time @property(assign,nonatomic)NSTimeInterval duration; //Toast disappear animation is enabled @property(assign,nonatomic)BOOL dismissToastAnimated; //Toast display position @property (assign, nonatomic) FFToastPosition toastPosition; //Toast display type @property (assign, nonatomic) FFToastType toastType; //Whether it is automatically hidden. AutoDismiss, enableDismissBtn, dismissBtnImage The three properties are only valid for Toast that pops up from the center of the screen @property(assign,nonatomic)BOOL autoDismiss; //Whether the hidden button is displayed in the upper right corner @property(assign,nonatomic)BOOL enableDismissBtn; //Hide the button's icon @property (strong, nonatomic) UIImage* dismissBtnImage;

After setting the properties, you can call the following method to display it:

/** Show a Toast */ - (void)show;

or:

/** Show a Toast @param handler Toast click callback */ - (void)show:(handler)handler;

E.g:

FFToast *toast = [[FFToast alloc]initToastWithTitle:@"title" message:@"Message content......." iconImage:[UIImage imageNamed:@"fftoast_info"]]; toast.toastPosition = FFToastPositionBelowStatusBarWithFillet; toast.toastBackgroundColor = [UIColor colorWithRed:75.f/255.f green:107.f/255.f blue:122.f/255.f alpha:1.f]; [toast show:^{ //Toast is called when clicked }];//[toast show];

If you want to customize a Toast from the middle, you can call the following method:

/** Show a custom Toast in the middle @param customToastView Customized ToastView @param autoDismiss Whether it is automatically hidden @param duration Display duration (autoDismiss = NO this parameter will be invalid) @param enableDismissBtn Whether to show the hidden button @param dismissBtnImage Hide button image (enableDismissBtn = NO this parameter will be invalid) @return Toast */ - (instancetype)initCentreToastWithView:(UIView *)customToastView autoDismiss:(BOOL)autoDismiss duration:(NSTimeInterval)duration enableDismissBtn:(BOOL)enableDismissBtn dismissBtnImage:(UIImage*)dismissBtnImage;
(责任编辑:ioter)

用户喜欢...

iOS开源:WJClipsButton-Clips 按钮的完整实现

效果 要求 Swift 3.0 iOS 8.0 Xcode 8.0 安装 WJClipsButton is available through CocoaPods . To install it, simply add the following line to your Podfile: pod "WJClipsButton" 使用 Code Import import WJClipsButton Init Setup let wjButton = WJCl...


WCDB:微信开源的高效、完整、易用的移动数据库框架

WCDB是一个高效、完整、易用的移动数据库框架,基于 SQLCipher ,支持iOS, macOS和Android。 WCDB for iOS/macOS 基本功能 WINQ (WCDB语言集成查询): 通过WINQ,开发者无须为了拼接SQL的字符串而写一大坨胶...


33 款主宰 2017 iOS 开发的开源库

你好, iOS 开发者们 !我的名字是 Pawel,是一名 iOS 独立开发者,也是 Enter Universe 的作者。 大概在两年前,我发布了 。这篇文章是我的一个最佳纪录(用户好评数): 因为有 15.5万人 关注过...


iOS开源:CBPic2ker - 图片选择,不但酷而且美还支持人脸识别

效果 特性 酷 给你丝滑的美 人脸识别 版本要求 iOS 8.0 安装 CBPic2ker 已经支持了CocoaPods. 只要在你的 Podfile 文件中添加下面的语句即可: pod "CBPic2ker" 不要忘记在info.plist文件中添加描述: 使用...


iOS开源:iOSPalette-图片精确提取主色调算法

Objective-C版本的Google Palette算法在Java.A工具中提取了一个图像的主要颜色。与传统的算法相比,iOSPalette可以帮助您提取更有可能成为“主色”的主色。它不是 总是像素数中最大的。 2.Why iOS-...


IOS开源:HHBadgeHUD-一款更 Q 的通知图标控件(OC)

一款更Q的通知图标控件。 演示项目 查看并运行 HHBadgeHUDDemo/HHBadgeHUDDemo.xcodeproj 特性 无侵入性 : 轻量 : 易扩展 : 使用方法 ###数字图标样式 // 1. 给UIView添加通知图标self.oneView.hh_badge = [HHCountB...


iOS开源:UILabel-可设置字间距,行间距等

屏幕快照 2016-04-14 下午9.58.53.png 实现的功能: 简单的利用Runtime给UILabel添加了属性 字间距 行间距 设置下划线 设置关键字 自适应宽高 详细用法请查看Demo...


iOS开源-轻量级 JSON 转 Model 框架,使用链式编程,无侵入

SuperKVC is a light-weight injection framework to convert JSON to Model. SuperKVC has its own config DSL which provides a chainable way of describing your injection config concise and readable. SuperKVC supports iOS and macOS. Samples are at the Su...


iOS开源:Magnetic - 可定制地类似 Apple Music 磁力吸引式泡泡选择器组件

Magneticis a customizable bubble picker like the Apple Music genre selection. $ pod try Magnetic 要求 iOS 9.3+ Xcode 8.0+ Swift 3.0+ 使用 A Magnetic object is an SKScene . To display, you present it from an SKView object. import Magneticclass V...


iOS开源:AAChartKit -一款极其精美的 iOS 开源图表库

AAChartKit项目,是在流行的开源前端图表库 Highcharts 的基础上,封装的面向对象的,一组简单易用,极其精美的图表绘制控件. 适配 iOS 8, 支持ARC,支持 OC语言,配置简单. 功能强大,支持柱状图 条形图...