Step-by-step learning about the properties of iOS (UISlider and Uiswitch)

Source: Internet
Author: User

Basic Control-uislider (slider)

Create a slider view to determine its position and size (height can be ignored)

UISlider *slider = [[UISlider alloc] Initwithframe:cgrectmake (50, 100, 200, 0.0)];

Set the range and default value of the slider

Slider.minimumvalue = 0.0;//Maximum Value

Slider.maximumvalue = 50.0;//Minimum value

Set a default value for the slider

Slider.value = 22.0;

slider.continuous = YES;

Set the background color of the slider

Slider.backgroundcolor = [Uicolor Redcolor];

Setting up Response Events

[Slider addtarget:self action: @selector (sliderchanged:) forcontrolevents:uicontroleventeditingchanged];

[Self.view Addsubview:slider];

Base control-uiswitch (switch)

Uiswitch *st = [[Uiswitch alloc] Initwithframe:cgrectmake (100.0F, 20.0F)];

Setting the initialization state of Uiswitch

st.on=yes;//set the side of the initial no

The color at which switch is on

St.ontintcolor = [Uicolor Purplecolor];

The color of switch when off

St.tintcolor = [Uicolor Yellowcolor];

Set the on icon

St.onimage = [UIImage imagenamed:@ "Ondemo"];

Set the on icon

St.offimage = [UIImage imagenamed:@ "Startdemo"];

Set the color of your thumb

St.thumbtintcolor = [Uicolor Greencolor];

Setting the initialization state of Uiswitch

[Self.view addsubview:st];

Step-by-step learning about the properties of iOS (UISlider and Uiswitch)

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.