1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- //
- // CWOperateItemView.swift
- // ColorfulWallpaper
- //
- // Created by ni on 2024/9/19.
- //
- import Foundation
- import UIKit
- class CWOperateItemView: UIControl {
- lazy var iconView: UIImageView = .simpleImage(imageName: "")
- lazy var titleLabel: UILabel = .simpleLabel(text: "", font: .systemFont14, color: .black)
- var type: CWOperateType = .like
- override init(frame: CGRect) {
- super.init(frame: frame)
- addChildren()
- makeConstraints()
- }
- convenience init(imgName: String, title: String, type: CWOperateType) {
- self.init(frame: .zero)
- iconView.image = .init(named: imgName)
- titleLabel.text = title
- self.type = type
- }
- func addChildren() {
- addSubview(iconView)
- addSubview(titleLabel)
- }
- func makeConstraints() {
- iconView.snp.makeConstraints { make in
- make.leading.equalToSuperview().offset(16)
- make.width.height.equalTo(28)
- make.verticalEdges.equalToSuperview().inset(18)
- }
- titleLabel.snp.makeConstraints { make in
- make.leading.equalTo(iconView.snp.trailing).offset(12)
- make.trailing.equalToSuperview().offset(-16)
- make.centerY.equalTo(iconView)
- }
- }
- required init?(coder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
- }
|