Properties of the UISlider

Source: Internet
Author: User

Self.window = [[UIWindow alloc]initwithframe:[uiscreen mainscreen].bounds];

Self.window.backgroundColor = [Uicolor Whitecolor];

[Self.window makekeyandvisible];

UISlider *s = [[UISlider alloc]init];

Set the value of the slider to worth to 1 when the slider is the maximum

S.value = 1;

S.frame = CGRectMake (10, 30, 300, 60);

S.backgroundcolor = [Uicolor Greencolor];

Set the minimum worth to 1 when the minimum value defaults to 0

S.minimumvalue = 1;

Set the maximum value

S.maximumvalue = 0;

Sets the color of the slider that has been slid over one end

S.minimumtracktintcolor = [Uicolor Redcolor];

Set not slide past one end slider color

S.maximumtracktintcolor = [Uicolor blackcolor];

Sets the minimum value one end of the picture, squeezing the slider width

S.minimumvalueimage = [UIImage imagenamed:@ "BQD"];

Sets the maximum value one end of the picture, squeezing the slider width

S.maximumvalueimage = [UIImage imagenamed:@ "BQD"];

Set the slider color, seemingly invalid, may be the default when the picture, has covered the color

S.thumbtintcolor = [Uicolor Yellowcolor];

Setting has slipped past one end of the slide bar background picture, will overwrite the previous color below the same

[s Setminimumtrackimage:[uiimage imagenamed:@ "BQD"] forstate:uicontrolstatenormal];

Set not to slide over one end slider background picture picture Max

[s Setmaximumtrackimage:[uiimage imagenamed:@ "BQD"] forstate:uicontrolstatenormal];

Set slider picture background cover Slider

[s Setthumbimage:[uiimage imagenamed:@ "BQD"] forstate:uicontrolstatenormal];

The most important thing is to do it according to the sliding event.

This is similar to the button but the event of the button is pressed and the event here is the uicontroleventvaluechanged value change is the event

[S addtarget:self action: @selector (GetValue:) forcontrolevents:uicontroleventvaluechanged];

Set a label to display the value of the change in real time

It's got to be a global variable, so it's not Uilabel *label, and the direct initialization can

UILabel *label = [[UILabel alloc]initwithframe:cgrectmake (30, 100,300,50)];

Label.text = @ "value";

s.continuous = NO;

[Self.window Addsubview:label];

[Self.window addsubview:s];

return YES;

}

-(void) GetValue: (ID) sender{

UISlider *s1 = (uislider*) sender;

Label.text = [NSString stringwithformat:@ "%f", S1.value];

//}

Properties of the UISlider

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.