把两个uiimageView放在后台

时间:2011-07-25 12:16:52

标签: iphone xcode animation background uiimageview

这是我的代码:

-(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发送到背景,因此背景在蓝色和粉红色之间变化。我该怎么办?对不起我的英语我是法国人:/

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

可能有用

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

通过更改可以实现的backgroundimage名称。