Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug]: #492

Closed
yue784069352 opened this issue Apr 17, 2020 · 3 comments
Closed

[bug]: #492

yue784069352 opened this issue Apr 17, 2020 · 3 comments

Comments

@yue784069352
Copy link

经过 很多次的试验和方法 去掉tabbar的黑线是可以的 但是设置阴影的话是没有效果的 希望还能顺带不规则Button的也是阴影



Base Info for this issue

  1. Version:Latest Version as here
  2. Language of App :Objective-C/Swift
  3. iOS System Version:iOS12
  4. Prototype(是否是真机):YES
  5. Issue Type:Crash、Bug、Enhancement(希望能支持一个新需求)、Q-A

1. How to reproduce the problem.

2. Please help me in this way.

3. Here is a Demo.

4. Here is my Debug log


@Steven-Yung
Copy link

我遇到的问题是iOS13以下TabBar黑边无法去掉的问题,经过多次试验,是获取cyl_tabShadowImageView有问题,在iOS13系统下能正常获取,iOS12到iOS9都不能正常获取,于是我改了下代码能正常获取了,不知道是不是跟你一样的情况
原代码如下:UIView+CYLTabBarControllerExtention.m

- (UIImageView *)cyl_tabShadowImageView {
    UIView *subview = [self cyl_tabBackgroundView];
    if (!subview) {
        return nil;
    }
    NSArray<__kindof UIView *> *backgroundSubviews = subview.subviews;
    if (backgroundSubviews.count > 1) {
        for (UIView *subview in backgroundSubviews) {
            if (CGRectGetHeight(subview.bounds) <= 1.0 ) {
                return (UIImageView *)subview;
            }
        }
    }
    return nil;
}

修改如下:

- (UIImageView *)cyl_tabShadowImageView {
    if (@available(iOS 10.0, *)) {
        //iOS10及以上这样获取ShadowImageView:
        UIView *subview = [self cyl_tabBackgroundView];
        if (!subview) {
            return nil;
        }
        NSArray<__kindof UIView *> *backgroundSubviews = subview.subviews;
        //iOS13系统backgroundSubviews.count > 1可行,12及以下就不可行了
        if (backgroundSubviews.count >= 1) {
            for (UIView *subview in backgroundSubviews) {
                if (CGRectGetHeight(subview.bounds) <= 1.0 ) {
                    return (UIImageView *)subview;
                }
            }
        }
    } else {
        //iOS9这样获取ShadowImageView:
        for (UIView *subview in self.subviews) {
            if (CGRectGetHeight(subview.bounds) <= 1.0 ) {
                return (UIImageView *)subview;
            }
        }
    }
    return nil;
}

初始化TabBarController这么干:

//隐藏黑边:
[_tabBarController hideTabBarShadowImageView];
//增加阴影效果:
_tabBarController.tabBar.layer.shadowColor = UIColorMakeWithHex(@"#EEEEEE").CGColor;
_tabBarController.tabBar.layer.shadowRadius = 1.0;
_tabBarController.tabBar.layer.shadowOpacity = 1.0;
_tabBarController.tabBar.layer.shadowOffset = CGSizeMake(0, -1);
_tabBarController.tabBar.layer.masksToBounds = NO;
_tabBarController.tabBar.clipsToBounds = NO;

@ChenYilong
Copy link
Owner

好的!我改下.

@ChenYilong
Copy link
Owner

已发布

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants