我正在尝试在Resources文件夹的子目录中获取所有png文件的数组.在我的应用程序资源文件夹中,我创建了一个名为"images"的文件夹.该文件夹包含我需要显示的所有png文件.
这是我尝试获取路径的方式:
NSString *imagepath = [NSString stringWithFormat:@"%@/%@",[[NSBundle mainBundle] bundlePath],@"images/"];
NSLog(@"Path to Images: %@", imagepath);
NSArray * paths = [NSBundle pathsForResourcesOfType: @"png" inDirectory:imagepath];
NSMutableArray * allImageNames = [[NSMutableArray alloc] init];
for ( NSString * path in paths )
{
if ( [[path lastPathComponent] hasPrefix: @"AQ"] )
continue;
[allImageNames addObject: [path lastPathComponent]];
}
Run Code Online (Sandbox Code Playgroud)
这样我得到一个像.../appname.app/images的路径
但是,如果我尝试这样做,数组总是空的.我究竟做错了什么?
格拉茨,扎拉克
我实际上在我的iOS应用程序中设置了动画UILabel的问题.在网络上搜索代码片段2天后,仍然没有结果.
我找到的每个样本都是关于如何为UIImage制作动画,将其作为子视图添加到UIView中.有没有关于动画UILabel的好例子?我通过设置alpha属性为闪烁动画找到了一个很好的解决方案,如下所示:
我的功能:
- (void)blinkAnimation:(NSString *)animationID finished:(BOOL)finished target:(UIView *)target
{
NSString *selectedSpeed = [[NSUserDefaults standardUserDefaults] stringForKey:@"EffectSpeed"];
float speedFloat = (1.00 - [selectedSpeed floatValue]);
[UIView beginAnimations:animationID context:target];
[UIView setAnimationDuration:speedFloat];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(blinkAnimation:finished:target:)];
if([target alpha] == 1.0f)
[target setAlpha:0.0f];
else
[target setAlpha:1.0f];
[UIView commitAnimations];
}
Run Code Online (Sandbox Code Playgroud)
在UILabel上调用我的函数:
[self blinkAnimation:@"blinkAnimation" finished:YES target:labelView];
Run Code Online (Sandbox Code Playgroud)
但是Pulse或缩放动画怎么样?