我使用UIProgressView进行音乐播放进度条,它在ios6或之前使用得很好,但ios7中存在问题。当我将ipad从Landscape旋转到Portrait时,它就丢失了。
以下代码
[_playerBar setMiddleTrackImage:[IMG(@"player_progress_loading") resizableImageWithCapInsets:UIEdgeInsetsMake(4, 3, 5, 4)]];
[_playerBar setMaximumTrackImage:[IMG(@"player_progress") resizableImageWithCapInsets:UIEdgeInsetsMake(4, 3, 5, 4)]];
- (void)setMiddleTrackImage:(UIImage *)middleTrackImage {
[_progressView setProgressImage:middleTrackImage];
}
- (void)setMaximumTrackImage:(UIImage *)maximumTrackImage {
[_progressView setTrackImage:maximumTrackImage];
}
_progressView = [[UIProgressView alloc] initWithFrame:rect];
[_progressView setProgressViewStyle:UIProgressViewStyleBar];
_progressView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
_progressView.center = CGPointMake(_slider.center.x, _slider.center.y+1);
_progressView.userInteractionEnabled = NO;
[_slider addSubview:_progressView];
_progressView.progressTintColor = [UIColor darkGrayColor];
_progressView.trackTintColor = [UIColor lightGrayColor];
任何帮助表示赞赏!
答案 0 :(得分:0)
我认为缺少UIprogressView是因为UIProgressView高度等于0.当你旋转到Portrait时,resizableImageWithCapInsets:UIEdgeInsetsMake()和autoresizingMask改变高度
你可以使用
_progressView.autoresizingMask = UIViewAutoresizingFlexibleWidth
并调整高度