// // KMPageEditBaseItemView.swift // PDF Master // // Created by tangchao on 2023/1/11. // import Cocoa typealias KMPageEditItemViewItemClick = (_ index: Int, _ value: Any) -> () class KMPageEditBaseItemView: NSView { lazy var titleLabel: NSTextField = { let label = NSTextField(labelWithString: "") label.font = NSFont.systemFont(ofSize: 14) return label }() private var myContentInset: NSEdgeInsets = NSEdgeInsetsMake(8, 16, 0, 0) var contentInset: NSEdgeInsets { get { return myContentInset } set { self.myContentInset = newValue self.layoutSubtreeIfNeeded() } } var itemClick: KMPageEditItemViewItemClick! override var isFlipped: Bool { return true } override init(frame frameRect: NSRect) { super.init(frame: frameRect) initSubviews() } required init?(coder: NSCoder) { super.init(coder: coder) initSubviews() } public func initSubviews() { self.addSubview(self.titleLabel) } override func layout() { super.layout() self.titleLabel.frame = NSMakeRect(self.contentInset.left, self.contentInset.top, NSWidth(self.bounds)-self.contentInset.left-self.contentInset.right, 22) } }