Examples of IOS Uisegmentedcontrol

Source: Internet
Author: User
Tags uikit

#import <UIKit/UIKit.h>

@interface Viewcontroller:uiviewcontroller

@property (strong,nonatomic) Uiimageview *myimage;

@property (strong,nonatomic) Uitextview *myview;

@property (strong,nonatomic) Uisegmentedcontrol *mysegment;

#import "ViewController.h"

@interface Viewcontroller ()

@end

@implementation Viewcontroller

-(void) viewdidload

{

[Super Viewdidload];

Self. Myview=[[uitextview Alloc] Initwithframe:cgrectmake (60, 500, 300, 200)];

Self. Myview.font=[uifont Systemfontofsize:18];

Self. Myview.textcolor=[uicolor Redcolor];

Self. Myview.userinteractionenabled=no;

[Self.view addsubview:self. MyView];

Add Segment ID

Self. Mysegment=[[uisegmentedcontrol alloc] initwithitems:@[@ "carnivorous plant", @ "flower plant", @ "Woody plant", @ "multi-meat plant"];

Self. Mysegment.frame=cgrectmake (60, 100, 300, 50);

[Self.view addsubview:self. Mysegment];

Add a View

Self. Myimage=[[uiimageview Alloc] Initwithframe:cgrectmake (60, 180, 300,300)];

[Self.view addsubview:self. MyImage];

Add background

Self.view.backgroundcolor=[[uicolor alloc] initwithpatternimage:[uiimage imagenamed:@ "background map. png"];

Event

[Self. Mysegment addtarget:self Action: @selector (ValueChange) forcontrolevents:uicontroleventvaluechanged];

}

/**

* Trigger Event

*/

-(void) ValueChange

{

Switch (self. Mysegment.selectedsegmentindex)

{

Case 0:

Self. Myimage.image=[uiimage imagenamed:@ "carnivorous plant. jpg"];

[Email protected] "carnivorous plants are a kind of autonomic plants that capture and digest animals and gain nutrients (non-energy). Most of the prey of carnivorous plants are insects and arthropods. It grows in poor soils, especially in areas where nitrogen is absent, such as acidic swamps and rocky desertification. In 1875, Charles Darwin published his first paper on insect-eating plants. ";

Break

Case 1:

Self. Myimage.image=[uiimage imagenamed:@ "flower plant. png"];

[Email protected] "Hyacinth (scientific name: Hyacinthus orientalis L.): is a perennial herb ball root plant, the bulb oval, has a membranous cortex, the color of the skin film is positively correlated with the colors, not flowering when the shape such as garlic, the origin of the sea along the coast and Asia Minor area, is the discovery of flowering plants are the most fragrant of a species. ";

Break

Case 2:

Self. Myimage.image=[uiimage imagenamed:@ "woody plants. png"];

[Email protected] "Peach (scientific name: Amygdalus persica L.): Rose family, peach genus. Deciduous small trees; leaves narrow-elliptic to lanceolate, 15 cm long, 4 cm wide, apex growing and finely pointed, margin finely toothed, dark green glossy, leaf base with nectar glands. ";

Break

Case 3:

Self. Myimage.image=[uiimage imagenamed:@ "multi-meat plant. png"];

[Email protected] "Cactus is a spherical shape of the cacti plant collectively, there are many varieties. They are native to the desert, hi-temperature arid climate. Stems globose or elliptic, green, flowered in longitudinal ridges, cactus blooms generally in the early morning or evening. ";

Break

Default

Break

}

}

Examples of IOS Uisegmentedcontrol

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.