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