vicc / chameleon

Color framework for Swift & Objective-C (Gradient colors, hexcode support, colors from images & more).
Other
12.43k stars 1.31k forks source link

Setting theme causes coloring of UITableViewCell indicators #98

Closed anthonypuppo closed 8 years ago

anthonypuppo commented 8 years ago

Should be ignored on accessory buttons (as well as tint color set to the actual main color).

image

jonlambert commented 8 years ago

+1. Would love to know if there's a workaround to this.

anthonypuppo commented 8 years ago

@jonlambert I'm currently getting around this problem by using the following:

UIButton.appearanceWhenContainedInInstancesOfClasses([UITableView.self]).backgroundColor = UIColor.clearColor()

This is, however, not a long term solution.

sumowesley commented 8 years ago

Outstanding tip to provide the work round the issue by @AnthonyOSX. Objective-C version below:

[[UIButton appearanceWhenContainedInInstancesOfClasses:@[[UITableView class]]] setBackgroundColor:[UIColor clearColor]];
vicc commented 8 years ago

Nice! Thanks @AnthonyOSX and @sumowesley . I'll definitely add this to the to do list for the next update.

connectdotz commented 8 years ago

I like the theme setting very much except the UIButton background..., end up had to manually set it to Clear as many have suggested. However this does not work for the case when we wanted different background colors for the buttons in the same container...

Giving there is no way to "unset" the UIAppearance once it is set, it would be great if we can pick and choose what entity (UIButton, UILabel etc) to apply the theme to so people can fine tune for what they need. Maybe an bitmask NS_Option or OptionSetType can be added for fine tuning?

colejd commented 8 years ago

Just wanted to note here that the same thing happens to the clipboard and undo/redo buttons at the top of the keyboard on an iPad. Setting the secondary color to UIColor.clearColor works if you aren't using your secondary color for anything else.

ashish-naik commented 6 years ago

I am facing issue with scope bar in table view controller in iOS11 . Am setting global theme with primary as flatBlue and secondary as flatGrey.

Scope bar as shown.

scopebar ios 11 issue

My delegate methods are a below.

`func searchBarTextDidBeginEditing(_ searchBar: UISearchBar) {

        let backgroundImage = UIImage(color: UIColor.white)

        if #available(iOS 11.0, *) {

            searchBar.showsScopeBar = true
            searchBar.sizeToFit()

           //this works for iOS 10 but in iOS 11 scope bar section appears blue
            //searchBar.scopeBarBackgroundImage = backgroundImage 

           //above statement  doesnt work in iOS 11 so trying below
            searchBar.setScopeBarButtonBackgroundImage(backgroundImage, for: .normal) 

            searchBar.setShowsCancelButton(true, animated: true)

            //trying to remove secondary color and add back in cancel delegate method
            Chameleon.setGlobalThemeUsingPrimaryColor(Constants.globalThemePrimaryColor,
                                                      withSecondaryColor: nil,
                                                      andContentStyle: .contrast)
        } else {

            searchBar.showsScopeBar = true
            searchBar.sizeToFit()
            searchBar.scopeBarBackgroundImage = backgroundImage
            searchBar.setShowsCancelButton(true, animated: true)
        }
    }`

setup as below

` override func viewDidLoad() {
        super.viewDidLoad()

        searchController.searchResultsUpdater = self
        searchController.obscuresBackgroundDuringPresentation = false
        searchController.searchBar.placeholder = "Search"
        if #available(iOS 11.0, *) {

            searchBar = searchController.searchBar
            searchController.searchBar.delegate = self

            if let textfield = searchBar.value(forKey: "searchField") as? UITextField {
                textfield.textColor = UIColor.blue
                if let backgroundview = textfield.subviews.first {

                    // Background color
                    backgroundview.backgroundColor = UIColor.white

                    // Rounded corner
                    backgroundview.layer.cornerRadius = 10;
                    backgroundview.clipsToBounds = true;

                }
            }

            navigationItem.searchController = searchController
            searchController.searchBar.scopeButtonTitles = ["All", "Pending", "Closed"]

        } else {

            tableView.tableHeaderView = searchBar
            searchBar.scopeButtonTitles = ["All", "Pending", "Closed"]
            searchBar.delegate = self
        }
}