How to read size of UISlider thumb image

前端 未结 5 1197
一生所求
一生所求 2021-01-18 07:02

I\'m trying to position an additional UIView centered above the thumb in a UISlider. To do this, I need the width of the thumb image. In iOS6, this works fine. I can use:

5条回答
  •  逝去的感伤
    2021-01-18 08:06

    You need to set the initial thumb image using setThumbImage forState. This works fine for me in iOS7 and returns the correct width of the image. The slider is setup in a storyboard and connected via an IBOutlet.

    - (void)viewDidLoad
    {
        [super viewDidLoad];
    
        [self.slider setThumbImage:[UIImage imageNamed:@"tick.jpg"] forState:UIControlStateNormal];
    
        float check = self.slider.currentThumbImage.size.width;
        NSLog(@"Check is %f", check);
    
    }
    

提交回复
热议问题