Change a UILabels text with a UISliders value

前端 未结 3 1957
有刺的猬
有刺的猬 2021-01-14 20:46

How I could show a UISliders value as a UILabels text?

3条回答
  •  青春惊慌失措
    2021-01-14 20:55

    //This is for getting the Int Value
    
    - (IBAction)sliderValueChanged:(UISlider *)sender 
    { 
      yourtextlabel.text =  [NSString stringWithFormat:@"%d", (int)yourslideroutletname.value];
    NSLog(@"the selider value==%@",yourtextlabel.text);
     }
    
    //This is for getting the float Value
    
    - (IBAction)sliderValueChanged:(UISlider *)sender 
    { 
      yourtextlabel.text =  [NSString stringWithFormat:@"%f", yourslideroutletname.value];
    NSLog(@"the selider value==%@",yourtextlabel.text);
     }
    

提交回复
热议问题