SCPromptView-Swift: 显示在顶部的提示控件 SCPromptView-Objective_C
你的star是我最大的动力
下载源码,将SCPromptView
文件夹拖进项目
pod 'SCPromptView-Swift'
SCPromptView 的用法,与tableView相似
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
}
///高度
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 : A prompt view which show in the top of the screen .
Your star is my biggest motivation.
Download the source code , copy folder SCPromptView
into your project.
pod 'SCPromptView'
The usage of SCPromptView is similar to the usage of 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 = ""
}
}
}
Override two basic function.
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
}
///高度
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?){
}