UISegmentedControl custom background image

雨燕双飞 提交于 2020-01-01 04:50:11

问题


I have UINavigationBar setup as image - some wood texture. I want to insert UISegmentedControl with 4 buttons on that bar. Buttons should have same texture with slightly changed tint.

One solution would be to change tint alpha of buttons background color, so that texture in background can get trough, but as I set alpha for tint in IB it doesn't save value, it always gets back to value 1.

I cant get UISegmentedControl to show background image, so finally gave up and decide to search for help... Effect that is desired is one in iBooks app, with buttons in Navigation Bar. Any link or small help would be appreciated..


回答1:


This post describes the steps involved and has sample code: http://idevrecipes.com/2010/12/13/wooduinavigation/




回答2:


https://github.com/xhan/PlutoLand/blob/master/PlutoLand/UI/PLSegmentView.h

a custom SegmentView that can specify two images(normal, clicked)




回答3:


Do not bother with one of those custom segmented control packages if you're on iOS 5 or later.

Per Dylan's suggestion, use the Appearance functionality in iOS 5+.

See the top answer here: Customizing Left & Right UISegmentedControl Buttons



来源:https://stackoverflow.com/questions/3386385/uisegmentedcontrol-custom-background-image

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