我想知道如何设置UIProgressView色调.有时,根据颜色,默认高度不允许正确查看进度.如何解决这个问题?
我需要UIProgressBar在UITableviewCell播放音频剪辑时显示输入.
我尝试运行a NSTimer然后尝试更新进度视图,但它不起作用.这是我的代码.请让我知道这种方法有什么问题.
运行计时器
self.timer = [NSTimer scheduledTimerWithTimeInterval:0.25
target:self
selector:@selector(updatePlayProgress)
userInfo:nil
repeats:YES];
Run Code Online (Sandbox Code Playgroud)
更新TableviewCell中的UIProgressView
- (void)updatePlayProgress {
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
NSLog(@"Duration %f", appDelegate.moviePlayer.duration);
NSLog(@"Current time %f", appDelegate.moviePlayer.currentPlaybackTime);
float timeLeft = appDelegate.moviePlayer.currentPlaybackTime/appDelegate.moviePlayer.duration;
// upate the UIProgress
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:playingIndex inSection:0];
FeedCell *cell = (FeedCell*)[self tableView:self.tblView cellForRowAtIndexPath:indexPath];
NSLog(@"Time left %f", timeLeft);
cell.progressPlay.progress = 0.5;
[cell.progressPlay setNeedsDisplay];
}
Run Code Online (Sandbox Code Playgroud)
的cellForRowAtIndexPath
fCell.progressPlay.alpha = 0.5;
fCell.progressPlay.tintColor = navigationBarColor;
[fCell.progressPlay setTransform:CGAffineTransformMakeScale(fCell.frame.size.width, fCell.frame.size.height)];
[fCell.progressPlay setHidden:NO];
return fCell;
Run Code Online (Sandbox Code Playgroud)
输出应该与此类似

我有以下代码:
AVPlayerItem *currentItem = [AVPlayerItem playerItemWithURL:soundURL];
[self.audioPlayer replaceCurrentItemWithPlayerItem:currentItem];
[self.audioPlayer play];
Run Code Online (Sandbox Code Playgroud)
这里soundURL是一个remoteURL.它工作正常.在AVPlayer完美播放音乐.我有一个进度条,我根据播放器的当前时间更新它.
一切正常.我的问题是当我向前拖动进度条audioplayer从新位置开始但是如果我拖动progressbar它不会从新位置开始实际上它从先前位置恢复.这是我的进度条拖动开始和停止代码:
- (IBAction)progressBarDraggingStart:(id)sender
{
if (self.audioPlayer.rate != 0.0)
{
[self.audioPlayer pause];
}
}
- (IBAction)progressBarDraggindStop:(id)sender
{
CMTime newTime = CMTimeMakeWithSeconds(self.progressBar.value, 1);
[self.audioPlayer seekToTime:newTime];
[self.audioPlayer play];
}
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮我解决这个问题吗?
我想以编程方式快速制作 UIProgressBar 吗?
这段代码有什么问题?
override func viewDidLoad() {
super.viewDidLoad()
let progressView = UIProgressView(progressViewStyle: .Bar)
progressView.center = self.view.center
progressView.frame = CGRectMake(0,0,50,20)
progressView.translatesAutoresizingMaskIntoConstraints = false
progressView.setProgress(0.5, animated: false)
self.view.addSubview(progressView)
}
Run Code Online (Sandbox Code Playgroud) 我想用UIKIT定制一个矩形进度条,就像吸引的图像一样.有没有任何源代码?Cocos2d与CCProgressTimer具有相同的功能,但我找不到任何UIKIT源代码.
