将两个 uiimageView 放在背景上

发布于 2024-11-26 03:39:07 字数 1134 浏览 0 评论 0原文

这是我的代码:

-(void)transition{
CATransition *applicationLoadViewIn = [CATransition animation];
[applicationLoadViewIn setDuration:2];
[applicationLoadViewIn setType:kCATransitionFade];
[applicationLoadViewIn setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];
[[self.view layer] addAnimation:applicationLoadViewIn forKey:kCATransitionFade];
    imgView2 =   [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bluefont.png"]];          


if(self.view.layer.sublayers.count<=2)

{
    [[[self view] layer] addSublayer:[imgView2 layer]];
}
else {

    [[self.view.layer.sublayers lastObject] removeFromSuperlayer];
}

[imgView2 release];
}


- (void)viewDidLoad {
[super viewDidLoad];
        imgView =   [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"pinkfont.png"]];           
[[[self view] layer] addSublayer:[imgView layer]];
    [imgView release];
[NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(transition) userInfo:nil repeats:YES];

}

我想将 imgView2 和 imgView 发送到背景,因此背景在蓝色和粉色之间变化。我该怎么做?抱歉我的英语我是法国人:/

here is my code:

-(void)transition{
CATransition *applicationLoadViewIn = [CATransition animation];
[applicationLoadViewIn setDuration:2];
[applicationLoadViewIn setType:kCATransitionFade];
[applicationLoadViewIn setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];
[[self.view layer] addAnimation:applicationLoadViewIn forKey:kCATransitionFade];
    imgView2 =   [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bluefont.png"]];          


if(self.view.layer.sublayers.count<=2)

{
    [[[self view] layer] addSublayer:[imgView2 layer]];
}
else {

    [[self.view.layer.sublayers lastObject] removeFromSuperlayer];
}

[imgView2 release];
}


- (void)viewDidLoad {
[super viewDidLoad];
        imgView =   [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"pinkfont.png"]];           
[[[self view] layer] addSublayer:[imgView layer]];
    [imgView release];
[NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(transition) userInfo:nil repeats:YES];

}

I want to send imgView2 and imgView to the background, thus the background is changing between the blue and pink colour.How can I do this please ? sorry for my english I'm french :/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小矜持 2024-12-03 03:39:07

通过使用框架,您可以将两个图像视图添加到背景

by using the frames you can add two imageviews to the background

七七 2024-12-03 03:39:07

这可能很有用。

self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"image.png"]];

通过更改背景图像名称即可实现,

It may be useful

self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"image.png"]];

By changing the backgroundimage name you can achieve.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文