SCPromptView
SCPromptView : 顯示在頂部的提示控件
Swift版
你的star是我最大的動力
已適配iPhoneX
安裝
手動安裝
下載源碼,將SCPromptView
文件夾拖進(jìn)項(xiàng)目
CocoaPod
pod 'SCPromptView'
使用
SCPromptView 的用法,與tableView相似
創(chuàng)建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;
}
//讀取參數(shù)
-(void)sc_loadParam:(id)param{
NSString *text = param;
self.textLabel.text = text;
}
@end
重寫兩個(gè)基礎(chǔ)方法
注冊
SCPROMPT_REGISTER([TestPromptView class],@"test")
SCPROMPT_REGISTER([ResultPromptView class], @"result")
發(fā)送顯示命令
///隨機(jī)顏色顯示
-(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 子控件讀取數(shù)據(jù)
*/
-(void)sc_loadParam:(id)param;
@optional
/**
* @brief 顯示時(shí)間
*/
-(NSTimeInterval)sc_showTime;
/**
* @brief 出現(xiàn)動畫時(shí)間
*/
-(NSTimeInterval)sc_showAnimationDuration;
/**
* @brief 隱藏動畫時(shí)間
*/
-(NSTimeInterval)sc_hideAnimationDuration;
/**
* @brief 即將執(zhí)行由手勢觸發(fā)的隱藏
* @return yes 隱藏 / no 不隱藏
*/
-(BOOL)sc_willHideByTap;
@end
SCPromptView
SCPromptView : A prompt view which show in the top of the screen .
your star is my biggest motivation
Install
Manually
Download the source code , copy folder SCPromptView
into your project.
CocoaPod
pod 'SCPromptView'
Usage
The usage of SCPromptView is similar to the usage of UITableView.
Create Custom View
#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
Override two basic function.
Register
SCPROMPT_REGISTER([TestPromptView class],@"test")
SCPROMPT_REGISTER([ResultPromptView class], @"result")
發(fā)送顯示命令
///show random color
-(void)clickBtn:(id)sender{
NSString * text =[NSString stringWithFormat:@"%d",_num];
SCPROMPT_SHOW(@"test",text)
_num++;
}
Other Api
@protocol SCPromptViewDelegate <NSObject>
@required
/**
* @brief 添加自定義的子控件
*/
-(void)sc_setUpCustomSubViews;
/**
* @brief 子控件讀取數(shù)據(jù)
*/
-(void)sc_loadParam:(id)param;
@optional
/**
* @brief 顯示時(shí)間
*/
-(NSTimeInterval)sc_showTime;
/**
* @brief 出現(xiàn)動畫時(shí)間
*/
-(NSTimeInterval)sc_showAnimationDuration;
/**
* @brief 隱藏動畫時(shí)間
*/
-(NSTimeInterval)sc_hideAnimationDuration;
/**
* @brief 即將執(zhí)行由手勢觸發(fā)的隱藏
* @return yes 隱藏 / no 不隱藏
*/
-(BOOL)sc_willHideByTap;
@end