简体   繁体   中英

UIScrollView: Animation banner effect

I have an UIScrollView with a PageControl, that show some pictures inside the view.

I'd like to create an animation, like a banner effect that changes the image after X seconds automatically.

  • Can do this with UIScrollView or should I use another way?

EDIT: @selector

- (void) changePage:(UIPageControl *)sender
{
    if ([pageControl currentPage]  < 3) {

        [pageControl setCurrentPage:[pageControl currentPage] + 1];
    } else{
        [pageControl setCurrentPage:0];
    }

}

UIScrollView is fine. You have to set pagingEnabled on the scrollView and after a certain time, change the page selected on the scrollView.

Its simple, pagingEnabled changes current position as a page.

Change pageControl.pagingEnabled into pageControl.scrollEnabled

scrollEnabled : Scrolls like x/y axis as you scroll

pagingEnabled : Scrolls like current scroll view as a page for each scroll.

Now replace your pagingEnabled into scrollEnabled .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM