动画 ios 启动画面



我正在尝试使我的初始屏幕显示 3 个图像。

尝试了多种事情,但如果有人能看到我在这里的代码中做错了什么,我仍然遇到错误?

@interface CydiaLoadingViewController : UIViewController
@end
%hook CydiaLoadingViewController
-(void)loadView {
%orig;
UIView *xiView = [[UIView alloc]initWithFrame:[UIScreen mainScreen].bounds];
xiView.backgroundColor = [UIColor whiteColor];
UIImage *image1 = [UIImage imageNamed:@"image1.png"];
UIImage *image2 = [UIImage imageNamed:@"image2.png"];
UIImage *image3 = [UIImage imageNamed:@"image3.png"];
UIImageView *logo =[[NSArray alloc] initWithObjects:image1,image2,image3, nil];
logo.imageView.animationRepeatCount = 7;
[logo.imageView startAnimating];
logo.frame = CGRectMake([UIScreen mainScreen].bounds.size.width / 2 - 60, [UIScreen mainScreen].bounds.size.height / 2 - 90, 120, 120);
logo.layer.masksToBounds = YES;
logo.layer.cornerRadius = 10;
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, [UIScreen mainScreen].bounds.size.height / 2 + 60, [UIScreen mainScreen].bounds.size.width, 40)];
label.text = @"Cydia";
label.textAlignment = NSTextAlignmentCenter;
[label setFont:[UIFont boldSystemFontOfSize:30]];
[xiView addSubview:logo];
[xiView addSubview:label];
[[self view] addSubview:xiView];
}
-(BOOL)hidesNavigationBar {
    return YES;
}
%end

错误

Tweak.xm:92:14: error: cannot initialize a variable of type 'UIImageView *' with an
      rvalue of type 'NSArray *'
UIImageView *logo =[[NSArray alloc] initWithObjects:image1,image2,image3, nil];

此错误是因为您在此行将 NSArray 的实例分配给了 UIImageView 变量。

UIImageView *logo =[[NSArray alloc] initWithObjects:image1,image2,image3, nil];

据我了解,您想使用UIImageView一一呈现这 3 张图像。在这种情况下,您应该正常创建UIImageView并使用UIImageViewanimationImages 属性。

例如

UIImageView *logo = [[UIImageView alloc] init];
logo.animationImages = [[NSArray alloc] initWithObjects:image1,image2,image3, nil];

最新更新