iOS开发UISlider设置图片

//设置图片

[self.slider setThumbImage:[UIImage imageNamed:@"[email protected]"] forState:UIControlStateNormal];

//设置图片后UISlider拖不到起始位置和末位置 需要重写次方法

-(CGRect)thumbRectForBounds:(CGRect)bounds trackRect:(CGRect)rect value:(float)value{
    
    rect.origin.x=rect.origin.x-10;
    
    rect.size.width=rect.size.width+20;
    
    return CGRectInset([super thumbRectForBounds:bounds trackRect:rect value:value],10,10);
}

你可能感兴趣的:(iOS开发UISlider设置图片)