2013-07-17 30 views
0

所以我有這個uiscrollerview ...每次5秒通過scrollview應該向上移動。如何使一個視圖上的滾動動畫

setcontentoffset正在工作,但它沒有動畫。喜歡它應該慢慢上升。

我的代碼如下

CGPoint bottomOffset = CGPointMake(0, newYLocationForScrollView); 

[scroll setContentOffset:bottomOffset animated:YES];

在此先感謝

+0

如何滾動ScrollView把代碼放在這裏 – iPatel

+0

[scrollView setContentOffset:offset animated:YES]; –

回答

0
[UIView animationWithDuration0.3f ^(void) { 

// code to do the transition 

}]; 

UIView Reference

[scrollView setContentOffset:offset animated:YES]; 

UIScrollView Reference

+0

它不工作... [UIView animationWithDuration:0.3f ^(void){scroll setContentOffset:bottomOffset動畫:YES]; }]; – antonoVodka

+0

這些是2個單獨的選項....你可以做一個或另一個[UIView animationWithDuration0.3f ^(void){scroll setContentOffSet:offSet]; }]; 或[scrollView setContentOffset:offset animated:YES]; –

+0

'[UIView animateWithDuration:1.00f delay:0.0f options:UIViewAnimationOptionCurveEaseOut 動畫:^ {scroll setContentOffset:bottomOffset]; } 完成:^(BOOL finished){ }];' – antonoVodka

1

使用滾動視圖scrollRectToVisible:animated:的方法,並給予animated財產YES

OR

[UIView animateWithDuration:1.2f animations:^{ 
     /// write code for animation 
    }]; 
+0

它不工作... [UIView animationWithDuration:0.3f ^(void){ [scroll setContentOffset:bottomOffset animated:YES]; }]; – antonoVodka

+0

[scroll setContentOffset:bottomOffset animated:YES];如果你使用動畫「YES」的這種方法,那麼不需要使用其他動畫bcoZ這個方法有它自己的動畫:) – iPatel

相關問題