0
我想在水平滾動中實現淡入/淡出,但我無法弄清楚如何訪問我的UIScrollView的子視圖中的按鈕。這就是我想要實現Fade in/out stackoverflow。如何訪問子視圖中的按鈕
這是我的代碼...
Game *game = (Game *)[_schedule.games objectAtIndex:i];
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(x, 20, 150, 100)];
[button setBackgroundImage:[UIImage imageNamed:game.opponent] forState:UIControlStateNormal];
//[button setTitle:game.opponent forState:UIControlStateNormal];
[_gameScrollList addSubview:button];
我怎樣才能觀察者添加到我的按鈕,可以這樣做?
[self.scrollView addObserver:[self.contentViews objectAtIndex:i]
forKeyPath:@"contentOffset"
options:NSKeyValueObservingOptionNew
context:@selector(updateAlpha:)];
讓我看看是否理解正確:你有一個滾動視圖,裏面有按鈕,當你滾動瀏覽它們時你想要這個淡入/淡出動畫?請在你的問題中更清楚 –