76 lines
2.2 KiB
Swift
76 lines
2.2 KiB
Swift
//
|
|
// AppDelegate+Config.swift
|
|
// ShortPlay
|
|
//
|
|
// Created by 曾觉新 on 2025/4/8.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
extension AppDelegate {
|
|
|
|
func appConfig() {
|
|
UIView.sp_Awake()
|
|
tabBarConfig()
|
|
// keyBoardStyle()
|
|
|
|
SPToast.config()
|
|
}
|
|
|
|
|
|
}
|
|
|
|
extension AppDelegate {
|
|
///配置tabBar样式
|
|
private func tabBarConfig() {
|
|
|
|
let tabBar = UITabBar.appearance();
|
|
|
|
|
|
let font = UIFont.fontRegular(ofSize: 10)
|
|
let normalColor = UIColor.color7F7F80()
|
|
let selectedColor = UIColor.colorFF0089()
|
|
|
|
|
|
let backgroundImage = UIImage(color: .clear)
|
|
let backgroundColor = UIColor.clear
|
|
let shadowImage = UIImage()
|
|
let shadowColor = UIColor.clear
|
|
|
|
let par = NSMutableParagraphStyle()
|
|
par.alignment = .center;
|
|
|
|
let normalAttributes = [NSAttributedString.Key.foregroundColor : normalColor,
|
|
NSAttributedString.Key.paragraphStyle : par,
|
|
NSAttributedString.Key.font: font,
|
|
]
|
|
let selectedAttributes = [NSAttributedString.Key.foregroundColor:selectedColor,
|
|
NSAttributedString.Key.paragraphStyle : par,
|
|
NSAttributedString.Key.font: font,
|
|
]
|
|
|
|
let appearance = UITabBarAppearance()
|
|
|
|
let normal = appearance.stackedLayoutAppearance.normal
|
|
normal.titleTextAttributes = normalAttributes
|
|
|
|
let selected = appearance.stackedLayoutAppearance.selected
|
|
selected.titleTextAttributes = selectedAttributes
|
|
|
|
appearance.backgroundImage = backgroundImage;
|
|
appearance.backgroundColor = backgroundColor;
|
|
appearance.shadowImage = shadowImage
|
|
appearance.shadowColor = shadowColor
|
|
appearance.backgroundEffect = nil
|
|
// 官方文档写的是 重置背景和阴影为透明
|
|
// appearance.configureWithTransparentBackground()
|
|
tabBar.standardAppearance = appearance;
|
|
if #available(iOS 15.0, *) {
|
|
tabBar.scrollEdgeAppearance = appearance
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|