57 lines
1.7 KiB
Swift
57 lines
1.7 KiB
Swift
//
|
|
// BRTabBarItemContainer.swift
|
|
// BeeReel
|
|
//
|
|
// Created by 长沙鸿瑶 on 2025/6/25.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
class BRTabBarItemContainer: UIControl {
|
|
|
|
var contentView: BRTabBarItemContentView? {
|
|
didSet {
|
|
oldValue?.removeFromSuperview()
|
|
|
|
if let contentView = contentView {
|
|
addSubview(contentView)
|
|
}
|
|
}
|
|
}
|
|
|
|
internal init(_ target: AnyObject?, tag: Int) {
|
|
super.init(frame: CGRect.zero)
|
|
self.tag = tag
|
|
self.addTarget(target, action: #selector(BRTabBar.selectAction(_:)), for: .touchUpInside)
|
|
self.addTarget(target, action: #selector(BRTabBar.highlightAction(_:)), for: .touchDown)
|
|
self.addTarget(target, action: #selector(BRTabBar.highlightAction(_:)), for: .touchDragEnter)
|
|
self.addTarget(target, action: #selector(BRTabBar.dehighlightAction(_:)), for: .touchDragExit)
|
|
self.backgroundColor = .clear
|
|
// self.isAccessibilityElement = true
|
|
}
|
|
|
|
internal required init?(coder aDecoder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
|
|
internal override func layoutSubviews() {
|
|
super.layoutSubviews()
|
|
if let contentView = contentView {
|
|
contentView.frame = self.bounds
|
|
// contentView.updateLayout()
|
|
}
|
|
}
|
|
|
|
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
|
|
var b = super.point(inside: point, with: event)
|
|
if !b {
|
|
for subview in self.subviews {
|
|
if subview.point(inside: CGPoint.init(x: point.x - subview.frame.origin.x, y: point.y - subview.frame.origin.y), with: event) {
|
|
b = true
|
|
}
|
|
}
|
|
}
|
|
return b
|
|
}
|
|
}
|