MonoTouch.Dialog: UISearchBar Color

浪尽此生 提交于 2019-12-23 18:30:02

问题


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, ""); 
            }
        }

回答1:


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 (e.g. 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.



来源:https://stackoverflow.com/questions/9969112/monotouch-dialog-uisearchbar-color

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!