AIMLoader 0.0.5

AIMLoader 0.0.5

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布上次发布2015年9月

Maciej Gad维护。



 
依赖关系
GKRToast~> 0.0.5
FLAnimatedImage~> 1.0
 

AIMLoader 0.0.5

GKRToast

为iOS重放的Android Toast信息,易于定制的动画。

如何使用

对于默认样式的Toast,只需写下

[GKRToast show:@"Your text"];

对于其他样式,请使用以下两个类之一 AIMToastAIMFancyToast,或创建自定义子类

可用的类和样式

GKRToast - Android外观的基础类

AIMToast - 适用于All in Mobile的类,背景和文字颜色可以轻松自定义

AIMFancyToast - 创建更复杂动画的示例

自定义子类

如果您想制作带有自定义布局和动画的Toast,应该创建一个GKRToast的子类,重写+ (GKRToastConfigure *)configure方法,并返回Toast的新配置。例如,如果您想创建一个从左侧打开的Toast,您应该写出以下内容:

+ (GKRToastConfigure *)configure {
    GKRToastConfigure *configure = [GKRToastConfigure new];

    CGFloat offset = CGRectGetWidth([UIScreen mainScreen].bounds) * 0.5f + 100;

    configure.animateShowLabel = ^(UIView *textContainer, UILabel *textLabel, MASConstraint *centerX, MASConstraint *centerY) {
        centerX.offset = -offset;
        [textContainer layoutIfNeeded];
        centerX.offset = 0;
        [UIView animateWithDuration:1.0f animations:^{
            [textContainer layoutIfNeeded];
        }];
    };
    return configure;
};

GKRToastConfigure属性

GKRToastConfigure对象有以下属性:

属性 类型 描述 默认值
backgroundView UIView * 全屏显示的背景 带有30%不透明度的背景颜色
textContainer UIView * 文本消息的容器 带有80%不透明度的背景颜色
textLabel UILabel * 显示消息文本的标签 白色文字颜色,行数设置为0
textEdgeInsets UIEdgeInsets textLabel的边距 左、右、上和下设置为10 Pt
hideTimeOut NSTimeInterval 显示时间(以秒为单位);如果设置为0,则永远不会自动隐藏 5s
animateShowLabel void(^)(UIView *textContainer, UILabel *textLabel, MASConstraint *centerX, MASConstraint *centerY) 在将textContainer添加到当前窗口后的block调用;centerXcenterY是为使Toast居中对屏幕设置约束的约束 0到1的alpha过渡在0.5秒内
animateShowBackground void(^)(UIView *backgroundView) 在将backgroundView添加到当前窗口后的block调用 0到1的alpha过渡在0.5秒内
animateHideLabel void(^)(UIView *textContainer, UILabel *textLabel, MASConstraint *centerX, MASConstraint *centerY) 当需要在当前窗口中移除 textContainer 时进行块调用;动画结束后,请务必调用 [textLabel removeFromSuperview][textContainer removeFromSuperview] 在 0.5 秒内从 1 到 0 的透明度过渡
animateHideBackground void(^)(UIView *backgroundView) 当需要在当前窗口中移除 backgroundView 时进行块调用;动画结束后,请务必调用 [backgroundView removeFromSuperview] 在 0.5 秒内从 1 到 0 的透明度过渡

在 YouTube 上查看完整视频

Check the full video