import UIKit
class CollectButton: UIControl {
//刪除按鈕
private var deleteBtn: UIButton?
//圖片
private var imageView: UIImageView?
//名字
private var titleLabel: UILabel?
//顯示數(shù)據(jù)
var item: CollectItem? {
didSet {
//圖片
self.imageView?.image = self.item?.image
//名字
self.titleLabel?.text = self.item?.name
}
}
override init(frame: CGRect) {
super.init(frame: frame)
//圖片
self.imageView = LFUtil.createImageView(CGRectMake(20, 20, 60, 60), imageName: nil)
self.addSubview(self.imageView!)
//名字
self.titleLabel = LFUtil.createLabel(CGRectMake(20, 80, 60, 20), text: nil)
self.titleLabel?.font = UIFont.systemFontOfSize(12)
self.titleLabel?.textAlignment = .Center
self.addSubview(self.titleLabel!)
//刪除按鈕
self.deleteBtn = LFUtil.createBtn(CGRectMake(0, 0, 40, 40), title: nil, bgImageName: "close", target: self, action: #selector(deleteAction))
//默認隱藏
self.deleteBtn?.hidden = true
self.addSubview(self.deleteBtn!)
}
//刪除操作
func deleteAction(){
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}```
UI: 自定制按鈕一
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。
相關(guān)閱讀更多精彩內(nèi)容
- 在iOS開發(fā)的工作當(dāng)中,Push和Pop經(jīng)常用于界面之間的跳轉(zhuǎn)和返回。蘋果在iOS7以后給導(dǎo)航控制器加了一個...
- 封裝了一個帶有中間凸起的自定制Tabbar,包含4個普通按鈕和中間的一個凸起按鈕- 首先封裝了一個UIButton...