ChenYilong / CYLTabBarController

[EN]It is an iOS UI module library for adding animation to iOS tabbar items and icons with Lottie, and adding a bigger center UITabBar Item. [CN]【中国特色 TabBar】一行代码实现 Lottie 动画TabBar,支持中间带+号的TabBar样式,自带红点角标,支持动态刷新。【iOS13 & Dark Mode & iPhone XS MAX supported】
MIT License
6.9k stars 1.45k forks source link

tabbar shadowImage异常,颜色从左到右变淡了 #586

Closed longitachi closed 2 years ago

longitachi commented 2 years ago

3A14DDED-5E41-42C3-B216-B691DB61FD20 您好,遇到个问题,设置tabbar shadowImage时候,会出现图中的情况,从左到右变淡了,代码如下

if #available(iOS 13.0, *) {
     let inlineLayoutAppearance = UITabBarItemAppearance()
    inlineLayoutAppearance.normal.titleTextAttributes = normalAttrs
    inlineLayoutAppearance.selected.titleTextAttributes = selectedAttrs

    let standardAppearance = UITabBarAppearance()
    standardAppearance.stackedLayoutAppearance = inlineLayoutAppearance
    standardAppearance.backgroundColor = .tabBarBackground
    standardAppearance.shadowImage = UIImage.imageWithColor(.orange, size: CGSize(width: 0.4, height: 0.4))
    tabBar.standardAppearance = standardAppearance
    if #available(iOS 15.0, *) {
        tabBar.scrollEdgeAppearance = standardAppearance
    }
} else {
    let tabBarItem = UITabBarItem.appearance()
    tabBarItem.setTitleTextAttributes(normalAttrs, for: .normal)
    tabBarItem.setTitleTextAttributes(selectedAttrs, for: .selected)
    UITabBar.appearance().backgroundColor = .tabBarBackground
    UITabBar.appearance().shadowImage = UIImage.imageWithColor(.seperator, size: CGSize(width: 0.4, height: 0.4))
}
longitachi commented 2 years ago

换成一张图片的方式了,用color转image的方式,小于1像素就会这样

liweican1992 commented 2 years ago

shadowImage改成这样试试,应该就好了

appearance.shadowImage = UIImage.cyl_image(with: UIColor.black, size: CGSize.init(width:UIScreen.main.bounds.size.width, height: 1/UIScreen.main.scale))