IOS UI Segmentedcontrol Uisegmentedcontrol Common Properties and usage

Source: Internet
Author: User

Some common attributes and usages in Uisegmentedcontrol

Sets the display of a pattern as a segment, requiring only the outline of the pattern, so that the color is a segmented background color

Nsarray *items = @[[uiimage imagenamed:@ "segmented1"],[uiimage imagenamed:@ "Segmented_4"],[uiimage imageNamed:@ " Segmented_3 "],[uiimage imagenamed:@" Segmented_2 "];

Nsarray *items = @[@ "video", @ "Music", @ "picture", @ "Software"];

[[Uisegmentedcontrol appearance]setbackgroundimage:items forstate:uicontrolstatenormal barMetrics: Uibarmetricsdefault];

Uisegmentedcontrol *segmentedc =[[uisegmentedcontrol Alloc]initwithitems:items];

Set the index segment to be a picture

[Segmentedc setimage:[uiimage imagenamed:@ "Segmented_4"] forsegmentatindex:2];

Set the default number of index segments as not selectable

[Segmentedc Setenabled:no Forsegmentatindex:2];

Set the width size of the first few paragraphs

[Segmentedc setwidth:10.0 forsegmentatindex:1];

[Segmentedc settitletextattributes:unselectedtextattributes Forstate:uicontrolstatenormal];

Segmentedc.backgroundcolor = [Uicolor Browncolor];

Sets whether the click Segment reverts to the original appearance, default to No

Segmentedc.momentary = YES;

Change the content of lower-level segments

[Segmentedc settitle:@ "YES" forsegmentatindex:0];

Rectangle set to rounded corners

SegmentedC.layer.cornerRadius = 20;

Set four dashed lines with rounded corners

SegmentedC.layer.masksToBounds = YES;

Segmentedc.selectedsegmentindex = 1; The first few split segments are selected by default

Segmentedc.tintcolor = [Uicolor Yellowcolor]; Set the segmentation boundary and font Color

Segmentedc.frame =cgrectmake (5, 20, 310, 40);

Set the response when clicking on an index segment

[Segmentedc addtarget:self Action: @selector (valuechanged:) forcontrolevents:uicontroleventvaluechanged];

[Self.window Addsubview:segmentedc];

[Segmentedc release];

IOS UI Segmentedcontrol Uisegmentedcontrol Common Properties and usage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.