Day_Count_Memory_Days/anniversary_Project/Main/AV_CustomTabBar.swift
2024-07-15 11:52:15 +08:00

45 lines
1.5 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// AV_CustomTabBar.swift
// anniversary_Project
//
// Created by 16 on 2024/4/15.
//
import UIKit
class AV_CustomTabBar: UITabBar {
private var middleButton: UIButton!
override init(frame: CGRect) {
super.init(frame: frame)
setupMiddleButton()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setupMiddleButton()
}
private func setupMiddleButton() {
middleButton = UIButton(type: .custom)
middleButton.setBackgroundImage(UIImage(named: "add"), for: .normal)
middleButton.adjustsImageWhenHighlighted = false
middleButton.translatesAutoresizingMaskIntoConstraints = false
middleButton.addTarget(self, action: #selector(middleButtonTapped), for: .touchUpInside)
addSubview(middleButton)
NSLayoutConstraint.activate([
middleButton.centerXAnchor.constraint(equalTo: centerXAnchor),
middleButton.centerYAnchor.constraint(equalTo: centerYAnchor, constant: -10), //
middleButton.widthAnchor.constraint(equalToConstant: 60), //
middleButton.heightAnchor.constraint(equalToConstant: 60)
])
}
@objc private func middleButtonTapped() {
//
// present
}
}