增加房间

This commit is contained in:
liyuhua
2024-03-07 16:56:48 +08:00
parent 3783cc5c95
commit bfee907f9e
45 changed files with 1191 additions and 29 deletions

View File

@@ -0,0 +1,67 @@
//
// UIButtom+.swift
// yinmeng-ios
//
// Created by duoban on 2024/3/6.
//
import UIKit
extension UIButton {
private static var clickRadius = "YinClickRadius"
var setBtnClickRadius: UIEdgeInsets? {
set {
objc_setAssociatedObject(self, &Self.clickRadius, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_COPY)
}
get {
return objc_getAssociatedObject(self, &Self.clickRadius) as? UIEdgeInsets ?? UIEdgeInsets.zero
}
}
///
override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
guard let inset = setBtnClickRadius else {
return super.point(inside: point, with: event)
}
var bounds = self.bounds
let x: CGFloat = -inset.left
let y: CGFloat = -inset.top
let width: CGFloat = bounds.width + inset.left + inset.right
let height: CGFloat = bounds.height + inset.top + inset.bottom
bounds = CGRect(x: x, y: y, width: width, height: height) //
return bounds.contains(point)
}
static func getCustomBtn(text:String? = nil,selectedText:String? = nil,font:UIFont? = nil,color:UIColor? = nil,selectedColor:UIColor? = nil,image:UIImage? = nil,selectedImage:UIImage? = nil,bgImage:UIImage? = nil) -> UIButton{
let customBtn = UIButton()
if let _text = text{
customBtn.setTitle(text, for: .normal)
}
if let _selectedText = selectedText{
customBtn.setTitle(selectedText, for: .selected)
}
if let _font = font{
customBtn.titleLabel?.font = font
}
if let _color = color{
customBtn.setTitleColor(color, for: .normal)
}
if let _selectedColor = selectedColor{
customBtn.setTitleColor(selectedColor, for: .selected)
}
if let _image = image{
customBtn.setImage(_image, for: .normal)
}
if let _selectedImage = selectedImage{
customBtn.setImage(_selectedImage, for: .selected)
}
if let _bgImage = bgImage{
customBtn.setBackgroundImage(_bgImage, for: .normal)
}
return customBtn
}
}