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

ReloadData() removes colour #9

Open
ArturGasparyan opened this issue May 19, 2017 · 1 comment
Open

ReloadData() removes colour #9

ArturGasparyan opened this issue May 19, 2017 · 1 comment

Comments

@ArturGasparyan
Copy link

ArturGasparyan commented May 19, 2017

Hello,

I'm using NightNight to support a day and night theme of my app. For this, I subscribe to a Notification of NightNight, which informs me when the user changes the theme.

Inside the method being called I merely say secondSwitch.reloadData()

This secondSwitch has two segments: index 0 is always grey, index 1 is blue or orange, depending on the theme.
There's also a firstSwitch which shows none of the following problems!

Whenever I update the theme, the notification fires, and the following happens:

If segment at index 1 is currently selected, it switches from blue to orange or vice versa as it should!
If segment at index 0 is currently selected, it should simply stay grey. However it loses any colour! It simply gets clear/transparent. If I grab the thumb of the control and start to drag, it reappears grey! Also switching it and switching it back shows the proper colour.

Here's my delegate method:

`if segmentedControl.tag == 0 {

switch index {
    case 1:
    
        return [FlatYellow(), FlatYellowDark()]
    case 2:
        
        return [FlatNavyBlue(), FlatNavyBlueDark()]
    default:
        
        return [FlatSkyBlue()]
}

}
else if segmentedControl.tag == 1 {

switch index {
    case 1:
    
        if NightNight.theme == .normal {
            
            return [FlatSkyBlue()]
        }
        
        return [FlatOrange()]

    default:
        
        return [FlatGrayDark()]
}

}

return [FlatSkyBlue()]
`

Here, secondSwitch has the tag 1, whilst firstSwitch has the tag 0.

I'd highly appreciate any tips as to what I do wrong! Thanks!

@ArturGasparyan
Copy link
Author

Anyone?

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

No branches or pull requests

1 participant