0428--iOS之UISegmentedControl类

Class

UISegmentedControl

A horizontal control made of multiple segments, each segment functioning as a discrete button.

 

Declaration

class UISegmentedControl : UIControl

Overview

A segmented control can display a title (an NSString object) or an image (UIImage object). The UISegmentedControl object automatically resizes segments to fit proportionally within their superview unless they have a specific width set. When you add and remove segments, you can request that the action be animated with sliding and fading effects.

    --分段控件可以显示标题(NSString对象)或图像(UIImage对象)。UISegmentedControl对象会自动调整段的尺寸以适应父视图的比例,除非它们有一个特定的宽度设置。当你添加和删除段时,你可以请求用滑动和淡入动画效果。

You register the target-action methods for a segmented control using the valueChanged constant as shown below.

           --使用valueChanged常量为分段控件注册目标动作方法,如下所示。

segmentedControl.addTarget(self, action: "action:", forControlEvents: .valueChanged)

How you configure a segmented control can affect its display behavior:

      --对分段控件的配置会影响它的显示行为

  • If you set a segmented control to have a momentary style, a segment doesn’t show itself as selected (blue background) when the user touches it. The disclosure button is always momentary and doesn’t affect the actual selection.
         --如果你将分段控件设置为瞬时样式时,当用户点击“分段控件”时,它不会显示为selected(蓝色背景)。箭头按钮总是短暂的,不会影响实际的选择

  • In versions of iOS prior to 3.0, if a segmented control has only two segments, then it behaves like a switch—tapping the currently-selected segment causes the other segment to be selected. On iOS 3.0 and later, tapping the currently-selected segment does not cause the other segment to be selected.
         --在3.0之前的iOS版本中,如果一个分段控件只有两个段,那么它的行为就像一个开关--轻敲当前选中的段,会导致另一个段也被选中。在ios3.0及以后版本中,点击当前选择的段并不会导致其他段也被选中。

Customizing Appearance               --自定义外观

In iOS 5 and later, you can customize the appearance of segmented controls using the methods listed in Customizing Appearance. You can customize the appearance of all segmented controls using the appearance proxy (for example, [UISegmentedControl appearance]), or just of a single control.

      --在ios5及以后版本中,您可以使用Customizing Appearance中列出的方法来自定义 分段控件 的外观。您可以使用appearance代理(例如,[UISegmentedControl appearance])定制所有分段控件的外观,或者只定制单个控件的外观。

When customizing appearance, in general, you should specify a value for the normal state of a property to be used by other

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值