我正在尝试创建一个淡出然后在打开页面时淡出的按钮。
这是我正在使用的当前代码,淡入/淡出按钮不起作用:
- (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;}];
这些都不起作用。有人对如何淡出子视图有任何提示吗?谢谢