SCPromptView 2.1.1

SCPromptView 2.1.1

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最新发布2018年12月

Csh089089维护。



SCPromptView

SCPromptView : 顶部显示提示控件 SCPromptView-Swift

你的 star 是我最大的动力

安装

手动安装

下载源码,将SCPromptView 文件夹拖进项目

CocoaPod

pod 'SCPromptView'

使用

SCPromptView 的用法,与tableView相似

创建view

#import "SCPromptView.h"

@interface TestPromptView : SCPromptView

@end
#import "TestPromptView.h"

@interface TestPromptView()
/**
 *   label
 */
@property (nonatomic,strong)UILabel *textLabel;
@end

@implementation TestPromptView
//初始化子控件
-(void)sc_setUpCustomSubViews{
    self.backgroundColor=  [UIColor colorWithRed:(arc4random()%255)/255.f green:(arc4random()%255)/255.f blue:(arc4random()%255)/255.f alpha:1];
    UILabel *textLabel = [[UILabel alloc]initWithFrame:self.contentView.bounds];
    textLabel.textColor = [UIColor whiteColor];
    textLabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:textLabel];
    self.textLabel = textLabel;
}
//读取参数
-(void)sc_loadParam:(id)param{
    NSString *text = param;
    self.textLabel.text = text;
}
@end

重写两个基础方法

注册

SCPROMPT_REGISTER([TestPromptView class],@"test")
SCPROMPT_REGISTER([ResultPromptView class], @"result")

发送显示命令

///随机颜色显示
-(void)clickBtn:(id)sender{
    NSString * text =[NSString stringWithFormat:@"%d",_num];
    SCPROMPT_SHOW(@"test",text)
    _num++;
}

其他Api

@protocol SCPromptViewDelegate <NSObject>
@required
/**
 *  @brief 添加自定义的子控件
 */
-(void)sc_setUpCustomSubViews;
/**
 *  @brief 子控件读取数据
 */
-(void)sc_loadParam:(id)param;

@optional
/**
 *  @brief 显示时间
 */
-(NSTimeInterval)sc_showTime;
/**
 *  @brief 滑动距离
 */
-(CGFloat)sc_slideDistance;
/**
 *  @brief 震动距离
 */
-(CGFloat)sc_shakeDistance;
/**
 *  @brief 出现动画时间
 */
-(NSTimeInterval)sc_showAnimationDuration;
/**
 *  @brief 隐藏动画时间
 */
-(NSTimeInterval)sc_hideAnimationDuration;
/**
 *  @brief 即将执行由手势触发的隐藏
 *  @return yes 隐藏 / no 不隐藏
 */
-(BOOL)sc_willHideByTap;

@end

SCPromptView

SCPromptView : 显示在屏幕顶部的提示视图。

您的支持是我最大的动力。

安装

手动

下载源代码,将文件夹 SCPromptView 复制到您的项目中。

CocoaPod

pod 'SCPromptView'

用法

SCPromptView 的使用与 UITableView 类似。

创建自定义视图

#import "SCPromptView.h"

@interface TestPromptView : SCPromptView

@end
#import "TestPromptView.h"

@interface TestPromptView()
/**
 *   label
 */
@property (nonatomic,strong)UILabel *textLabel;
@end

@implementation TestPromptView
//setUp subviews
-(void)sc_setUpCustomSubViews{
    self.backgroundColor=  [UIColor colorWithRed:(arc4random()%255)/255.f green:(arc4random()%255)/255.f blue:(arc4random()%255)/255.f alpha:1];
    UILabel *textLabel = [[UILabel alloc]initWithFrame:self.contentView.bounds];
    textLabel.textColor = [UIColor whiteColor];
    textLabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:textLabel];
    self.textLabel = textLabel;
}
//loadParam which you deliver via command
-(void)sc_loadParam:(id)param{
    NSString *text = param;
    self.textLabel.text = text;
}
@end

重写两个基本函数。

注册

SCPROMPT_REGISTER([TestPromptView class],@"test")
SCPROMPT_REGISTER([ResultPromptView class], @"result")

发送显示命令

///show random color
-(void)clickBtn:(id)sender{
    NSString * text =[NSString stringWithFormat:@"%d",_num];
    SCPROMPT_SHOW(@"test",text)
    _num++;
}

其他 API

@protocol SCPromptViewDelegate <NSObject>
@required
/**
 *  @brief 添加自定义的子控件
 */
-(void)sc_setUpCustomSubViews;
/**
 *  @brief 子控件读取数据
 */
-(void)sc_loadParam:(id)param;

@optional
/**
 *  @brief 显示时间
 */
-(NSTimeInterval)sc_showTime;
/**
 *  @brief 滑动距离
 */
-(CGFloat)sc_slideDistance;
/**
 *  @brief 震动距离
 */
-(CGFloat)sc_shakeDistance;
/**
 *  @brief 出现动画时间
 */
-(NSTimeInterval)sc_showAnimationDuration;
/**
 *  @brief 隐藏动画时间
 */
-(NSTimeInterval)sc_hideAnimationDuration;
/**
 *  @brief 即将执行由手势触发的隐藏
 *  @return yes 隐藏 / no 不隐藏
 */
-(BOOL)sc_willHideByTap;

@end