Custom UISegmentedControl

后端 未结 10 2088
我寻月下人不归
我寻月下人不归 2020-12-04 10:23

How do I make a custom UISegmentedControl?

I have 2 images, 1 that should be displayed when the segment is active and the other if the segment is inacti

10条回答
  •  臣服心动
    2020-12-04 11:07

    You can use the methods which are described in the iOS developer libary:

    http://developer.apple.com/library/ios/ipad/#documentation/uikit/reference/UISegmentedControl_Class/Reference/UISegmentedControl.html

    Scroll down to the "Customizing Appearance" section. There are methods to set background images for several button states, button divider images, etc.

    These methods are only available in iOS5 and later.

    @property tintColor  
    – backgroundImageForState:barMetrics:
    – setBackgroundImage:forState:barMetrics:
    – contentPositionAdjustmentForSegmentType:barMetrics:
    – setContentPositionAdjustment:forSegmentType:barMetrics:
    – dividerImageForLeftSegmentState:rightSegmentState:barMetrics:
    – setDividerImage:forLeftSegmentState:rightSegmentState:barMetrics:
    – titleTextAttributesForState:
    – setTitleTextAttributes:forState:
    

提交回复
热议问题