简体   繁体   中英

MonoTouch.Dialog: UISearchBar Color

In the March 31 release of MonoTouch.Dialog we aren't able to set the color of the UISearchBar anymore now as there is a new container object with hard coded colors.

Is there a simpler way to change the color of the UISearchBar ?

As a work around, I use this (knowing that the UISearchBar is the last added item to the new class SearchBarBackgroundView :

        SearchBarBackgroundView sb = TableView.TableHeaderView as SearchBarBackgroundView;
        if (sb != null)
        {
            try
            {
                if (sb.Subviews.Count () > 1)
                {
                    UISearchBar bar = sb.Subviews [sb.Subviews.Count () - 1] as UISearchBar;
                    if (bar != null)
                    {
                        bar.BackgroundColor = Settings.AppTintColor;
                        bar.TintColor = Settings.AppTintColor;
                    }
                }
            }
            catch (Exception e)
            {
                ExceptionPublisher.Pub (e, ""); 
            }
        }

This sounds like a bad feature regression. IMO the answer is not about a workaround, the best one would be: use an earlier revision, but finding when/why this occurred and make sure the next releases of MonoTouch does not impose this breaking change to other developers.

The best way to deal with those, since the MonoTouch.Dialog assembly is open source, is to track the revision where it occurred. You can see the history from github and then comment on the entry that cause the issue (eg this one looks like a candidate - maybe just because it does too many things in a single patch).

So if the revision before this one works then you add a comment (bottom of the page) about the issue. Everyone following the repository will get an email.

UPDATE : The patches that introduced the breaking changes has been reverted.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM