12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- //
- // KMPresentTableViewCell.swift
- // PDF Reader Pro
- //
- // Created by liujiajie on 5/14/24.
- //
- import Cocoa
- @objc enum KMPresentTableViewCellType: Int {
- case img = 0
- case text
- }
- class KMPresentTableViewCell: NSTableCellView{
-
- var contentView: NSView?
- var iv: NSImageView?
- var label: NSTextField?
- var type: KMPresentTableViewCellType?
-
- convenience init(type: KMPresentTableViewCellType) {
- self.init()
- // switch type {
- // case .img:
- // configuUIForImg()
- // case .text:
- // configuUIForText()
- // default:
- // break
- // }
- configuUi()
- self.type = type
- }
- // convenience init() {
- // self.init()
- // configuUi()
- // }
- func configuUIForImg() {
- self.iv = NSImageView(frame: .zero)
- self.addSubview(self.iv!)
-
- self.iv?.mas_makeConstraints({ make in
- make?.edges.equalTo()(self)
- // make?.left.equalTo()(self)
- // make?.top.equalTo()(self)?.offset()(12)
- // make?.width.equalTo()(16)
- // make?.height.equalTo()(16)
- })
- }
- func configuUIForText() {
- let tf = NSTextField(frame: .zero)
- self.label = tf
- self.label?.isBordered = false
- self.label?.drawsBackground = true
- self.label?.backgroundColor = NSColor.clear
- self.label?.isEditable = false
- self.addSubview(self.label!)
- self.label?.mas_makeConstraints({ make in
- make?.top.equalTo()(self)?.offset()(13)
- make?.left.equalTo()(self)
-
- })
- self.label?.textColor = KMAppearance.Layout.h0Color()
- self.label?.font = NSFont.systemFont(ofSize: 12)
- }
- func configuUi() {
- self.iv = NSImageView(frame: .zero)
- self.addSubview(self.iv!)
- self.iv?.mas_makeConstraints({ make in
- make?.left.equalTo()(0)
- make?.top.equalTo()(0)
- make?.width.equalTo()(32)
- make?.bottom.equalTo()(0)
- })
- let tf = NSTextField(frame: .zero)
- self.label = tf
- self.label?.isBordered = false
- self.label?.drawsBackground = true
- self.label?.backgroundColor = NSColor.clear
- self.label?.isEditable = false
- self.addSubview(self.label!)
- self.label?.mas_makeConstraints({ make in
- // make?.top.equalTo()(self)?.offset()(13)
- make?.left.equalTo()(self.iv?.mas_right)
- make?.right.equalTo()(self)
- make?.centerY.equalTo()(self)
- })
- self.label?.textColor = KMAppearance.Layout.h0Color()
- self.label?.font = NSFont.systemFont(ofSize: 12)
- self.label?.maximumNumberOfLines = 1
- }
- }
|