UISlider with ProgressView combined

后端 未结 9 1377
无人共我
无人共我 2020-11-29 16:07

Is there an apple-house-made way to get a UISlider with a ProgressView. This is used by many streaming applications e.g. native quicktimeplayer or youtube. (Just to be sure:

9条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-29 16:58

    Adding on matt's solution, note that as of iOS 7.0, implementing trackRectForBounds: is rendered impossible. Here is my solution to this problem :

    In your UISlider subclass, do this :

    -(void)awakeFromNib
    {
        [super awakeFromNib];
    
        UIImage* clearColorImage = [UIImage imageWithColor:[UIColor clearColor]];
        [self setMinimumTrackImage:clearColorImage forState:UIControlStateNormal];
        [self setMaximumTrackImage:clearColorImage forState:UIControlStateNormal];
    }
    

    with imageWithColor as this function :

    + (UIImage*) imageWithColor:(UIColor*)color
    {
        return [UIImage imageWithColor:color andSize:CGSizeMake(1.0f, 1.0f)];
    }
    

    That will properly take care of this annoying trackRectangle.

    I spent too much time looking for a solution to this problem, here's hoping that'll save some time to another poor soul ;).

提交回复
热议问题