我有一个按钮,我想为背景颜色设置动画,就好像它从底部到顶部填充一样。
现在我只是用动画改变颜色
IE
[UIView animateWithDuration:2.0 animations:^{
button.layer.backgroundColor = [UIColor redColor].CGColor;
} completion:NULL];
Run Code Online (Sandbox Code Playgroud)
这工作得很好,但我希望动画从底部向上填充,就像填充液体一样。
编辑:不确定它是否有区别,但按钮是圆形的
对于这个问题,我在这里查看了很多答案,但都无法解决。
这是我的问题,我试图在按下按钮时播放声音,这是文件所在的位置
这是我的代码
- (void)playSoundWithOfThisFile:(NSString*)fileName {
NSString *soundFilePath = [NSString stringWithFormat:fileName,
[[NSBundle mainBundle] resourcePath]];
NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:soundFileURL
error:nil];
player.numberOfLoops = 1;
[player play];
Run Code Online (Sandbox Code Playgroud)
}
当我运行代码时,值如下
fileName = Mummy.mp3
`soundFilePath = Mummy.mp3` (I've had it Sounds/Mummy.mp3 and this doesn't work either)
Run Code Online (Sandbox Code Playgroud)
soundFileURL = Mummy.mp3 - 文件:///
player = nil
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激。如果我发现它的错误只是一个没有信息的通用错误