我試圖創建一個淡出按鈕,然後打開頁面。用子查看按鈕淡入UIView
下面是我使用的當前代碼,這是行不通的,以淡入/淡出按鈕:
- (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;}];
無這些工作。有沒有人有關於如何淡出子視圖的任何提示?由於
這是完美的,它現在爲我工作。謝謝 – mhorgan