【发布时间】:2012-07-04 14:16:43
【问题描述】:
我正在尝试创建一个在我打开页面时淡出然后淡入的按钮。
这是我正在使用的当前代码,无法淡入/淡出按钮:
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view
{
if (index == 0) {
view = [[[NSBundle mainBundle] loadNibNamed:@"nib1" owner:self options:nil] lastObject];
}else {
view = [[[NSBundle mainBundle] loadNibNamed:@"nib2" owner:self options:nil] lastObject];
UIView *containView = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 60, 100)];
_btn = [UIButton buttonWithType:UIButtonTypeCustom];
_btn.frame = CGRectMake(30, 90, 40, 30 );
[_btn setBackgroundImage:[UIImage imageNamed:@"playButton.png"] forState:UIControlStateNormal];
[_btn addTarget:self action:@selector(fadeButton:) forControlEvents:UIControlEventTouchUpInside];
//[self fadeOut:_btn withDuration:1.0 andWait:1.0];
[containView addSubview:_btn];
[containView setAlpha:0.0];
[view addSubview:containView];
[UIView beginAnimations:nil context:nil];
[containView setAlpha:1.0];
[UIView commitAnimations];
}
return view;
}
我也试过使用:
[UIView animateWithDuration:0.5 animations:^{_btn.alpha = 1.0;}];
这些都不起作用。有人对如何淡出子视图有任何提示吗?谢谢
【问题讨论】:
标签: xcode ios5 uiview fading icarousel