Skip to content
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.

iOS 11 Fade no longer works #191

Open
jeromeDms opened this issue Oct 25, 2017 · 4 comments
Open

iOS 11 Fade no longer works #191

jeromeDms opened this issue Oct 25, 2017 · 4 comments

Comments

@jeromeDms
Copy link

Hi
Just updated to Xcode 9 and iOS 11 and it seems the fade behavior no longer works in TLYShyViewController.m (function _updateSubviewsAlpha)

The alpha property has no effect on the subviews to which it is applied.
Any tip, any workaround ?

Thanks

@jeromeDms
Copy link
Author

jeromeDms commented Oct 25, 2017

ok, here is the workaround :

- (void)_updateSubviewsAlpha:(CGFloat)alpha
{
    for (UIView* view in self.view.subviews)
    {
        bool isBackgroundView = view == self.view.subviews[0];
        bool isViewHidden = view.hidden || view.alpha < FLT_EPSILON;
        
        if (!isBackgroundView && !isViewHidden)
        {
            view.alpha = alpha;
      
#ifdef __IPHONE_11_0
            if(@available(iOS 11.0, *))
            {
                NSString* subViewClassName = NSStringFromClass([view class]);
                if ([subViewClassName containsString:@"UINavigationBarContentView"])
                {
                    for (UIView* subSubView in view.subviews)
                    {
                        subSubView.alpha = alpha;
                    }
                }
            }
#endif
        }
    }
}

@StainlessStlRat
Copy link

Seems it still doesn't fade the title view after the patch

@jeromeDms
Copy link
Author

jeromeDms commented Nov 27, 2017

You are right, I was using a custom title view, when using both custom title or normal title, the following updated patch should work (please confirm)

- (void)_updateSubviewsAlpha:(CGFloat)alpha
{
#ifdef __IPHONE_11_0
    if(@available(iOS 11.0, *))
    {
        if ([self.view isKindOfClass: [UINavigationBar class]])
        {
            UINavigationBar *tmpNavBar = (UINavigationBar *) self.view;
            tmpNavBar.tintColor = [tmpNavBar.tintColor colorWithAlphaComponent:alpha];
            
            if(tmpNavBar.topItem.title)
            {
                [tmpNavBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                       [tmpNavBar.tintColor colorWithAlphaComponent:alpha],NSForegroundColorAttributeName,nil]];
            }
        }
    }
#endif
    
    for (UIView* subView in self.view.subviews)
    {
        bool isBackgroundView = subView == self.view.subviews[0];
        bool isViewHidden = subView.hidden || subView.alpha < FLT_EPSILON;
        
        if (!isBackgroundView && !isViewHidden)
        {
            subView.alpha = alpha;
            
#ifdef __IPHONE_11_0
            if(@available(iOS 11.0, *))
            {
                NSString* subViewClassName = NSStringFromClass([subView class]);
                if ([subViewClassName containsString:@"UINavigationBarContentView"])
                {
                    for (UIView* subSubView in subView.subviews)
                    {
                        subSubView.alpha = alpha;
                    }
                }
            }
#endif
        }
    }
}

@StainlessStlRat
Copy link

StainlessStlRat commented Dec 12, 2017

Sorry for the delay, I can confirm it works for a normal title view now

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

No branches or pull requests

2 participants