【发布时间】:2012-06-28 06:31:34
【问题描述】:
我创建了一个应用程序,其中应用程序启动图像必须是动画的,并且我的按钮将使用 icarousel 以封面流效果显示..这是我的代码
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
carousel.type = iCarouselTypeInvertedWheel ;
CGRect ChaintopFrame = Chaintop.frame;
ChaintopFrame.origin.y = self.view.bounds.size.height;
//CGRect ChainbottomFrame = Chainbottom.frame;
//ChainbottomFrame.origin.y = self.view.bounds.size.height;
[UIView animateWithDuration:0.5
delay:1.0
options: UIViewAnimationCurveEaseOut
animations:^{
Chaintop.frame = ChaintopFrame;
//Chainbottom.frame = ChainbottomFrame;
}
completion:^(BOOL finished){
NSLog(@"Done!");
}];
}
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view
{
UIImage *buttonImage=[NSArray arrayWithObjects:[UIImage imageNamed:@"Cover_0.png"],
[UIImage imageNamed:@"Cover_1.png"],
[UIImage imageNamed:@"Cover_2.png"],
[UIImage imageNamed:@"Cover_3.png"],
[UIImage imageNamed:@"Cover_4.png"],
[UIImage imageNamed:@"Cover_5.png"],
[UIImage imageNamed:@"Cover_6.png"],
[UIImage imageNamed:@"Cover_7.png"],nil];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0, 0, 200.0f, 200.0f);
[button setImage:(UIImage*)[buttonImage objectAtIndex:index] forState:UIControlStateNormal];
[button addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside];
return button;
}
现在当我运行我的模拟器时,用于动画的图像返回并且按钮显示在前面。好消息是动画客栈图像正在工作......我也调整了我的 icarousel 视图的大小......
我错过了什么吗?...
【问题讨论】:
-
先添加图片再添加按钮框怎么样。
-
你的意思是说动画图像和按钮框架或按钮图像
-
你制作了一个可以点击的按钮图片并会做相应的动作吧?
-
是的。但我的问题是动画图像在按钮位于前面时返回...动画发生在 icarousel 按钮的后面...icarousel 是另一个视图,我调整了大小并将其放入UIView...
-
如何将图像添加为视图的子视图?你在分配图像吗?
标签: iphone ios xcode uianimation icarousel