SCPromptView-Swift
SCPromptView
SCPromptView-Swift: 显示在顶部的提示控件 SCPromptView-Objective_C
您的 star 是我最大的动力
安装
手动安装
下载源码,将 SCPromptView
文件夹拖到项目文件夹中。
CocoaPod
pod 'SCPromptView-Swift'
使用
SCPromptView 使用方式,类似于 tableView
创建view
class TestView: SCPromptView {
var label:UILabel?
override func sc_setUpCustomSubViews() {
backgroundColor = UIColor.clear
contentView.backgroundColor = UIColor.init(red:CGFloat(arc4random()%255)*1.0/255, green: CGFloat(arc4random()%255)*1.0/255, blue: CGFloat(arc4random()%255)*1.0/255, alpha:1)
contentView.layer.cornerRadius = 10
contentView.layer.masksToBounds = true
label = UILabel(frame: contentView.bounds)
label?.textColor = UIColor.white
label?.textAlignment = NSTextAlignment.center
contentView.addSubview(label!)
}
override func sc_loadParam(param: Any?) {
if param != nil {
let text = param as! String
label?.text = text
}else{
label?.text = ""
}
}
}
重写两个基本方法
注册
sc_prompt_register(viewClass:TestView.classForCoder(), showCommand: "test")
发送显示命令
///随机颜色显示
func clickBtn(){
let str:String = "\(num)"
sc_prompt_show(showCommand: "test", param: str)
num += 1
}
其他Api
///高度
func sc_height() -> CGFloat {
}
///滑动距离
func sc_slideDistanse() -> CGFloat {
}
///显示时间
func sc_showTime() -> TimeInterval {
}
///出现动画时间
func sc_showAnimationDuration() -> TimeInterval {
}
///隐藏动画时间
func sc_hideAnimationDuration() -> TimeInterval {
}
必须重写的方法
//MARK: load
///设置子控件
func sc_setUpCustomSubViews(){
}
func sc_loadParam(param:Any?){
}
SCPromptView
SCPromptView : 在屏幕顶部显示的提示视图。
您的点赞是我最大的动力。
安装
手动
下载源代码,将文件夹 SCPromptView
拷贝到您的项目中。
CocoaPod
pod 'SCPromptView'
使用方法
SCPromptView 的使用方法与 UITableView 类似。
创建自定义视图
class TestView: SCPromptView {
var label:UILabel?
override func sc_setUpCustomSubViews() {
backgroundColor = UIColor.clear
contentView.backgroundColor = UIColor.init(red:CGFloat(arc4random()%255)*1.0/255, green: CGFloat(arc4random()%255)*1.0/255, blue: CGFloat(arc4random()%255)*1.0/255, alpha:1)
contentView.layer.cornerRadius = 10
contentView.layer.masksToBounds = true
label = UILabel(frame: contentView.bounds)
label?.textColor = UIColor.white
label?.textAlignment = NSTextAlignment.center
contentView.addSubview(label!)
}
override func sc_loadParam(param: Any?) {
if param != nil {
let text = param as! String
label?.text = text
}else{
label?.text = ""
}
}
}
覆盖两个基本函数。
注册
sc_prompt_register(viewClass:TestView.classForCoder(), showCommand: "test")
显示
///show random color
///随机颜色显示
func clickBtn(){
let str:String = "\(num)"
sc_prompt_show(showCommand: "test", param: str)
num += 1
}
其他 API
///高度
func sc_height() -> CGFloat {
}
///滑动距离
func sc_slideDistanse() -> CGFloat {
}
///显示时间
func sc_showTime() -> TimeInterval {
}
///出现动画时间
func sc_showAnimationDuration() -> TimeInterval {
}
///隐藏动画时间
func sc_hideAnimationDuration() -> TimeInterval {
}
必须重写
//MARK: load
///设置子控件
func sc_setUpCustomSubViews(){
}
func sc_loadParam(param:Any?){
}