久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 UIScrollView 上以不同的速度滾動背景

Scroll a background in a different speed on a UIScrollView(在 UIScrollView 上以不同的速度滾動背景)
本文介紹了在 UIScrollView 上以不同的速度滾動背景的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

當有人用擦除手勢從左到右滾動內容時,我希望背景圖像以不同的速度滾動到相同的方向.就像這些經典游戲在 20 年前所做的一樣(記住這一點,有人嗎????)

When somebody does a wipe gesture to scroll the content from left to right, I would like to have a background image scrolling into the same direction, but at a different speed. Much like what these classic games did do 20 years ago (remember that, anybody????)

推薦答案

我通過使用 兩個 UIScrollView 實例完成了這個.第一個是顯示實際內容的位置,第二個(在 z 順序中位于第一個之后)是我移動較慢的背景的位置.從那里開始,頂部的 UIScrollView 附加了一個委托,當 contentOffset 更改時會收到通知.反過來,該委托以編程方式設置背景滾動條的 contentOffset,乘以一個常數以減慢相對于前景的滾動速度.因此,例如,您可能有以下內容:

I accomplished this by using two UIScrollView instances. The first is where the actual content is displayed, and the second (which is behind the first in z-order) is where I have my slower-moving background. From there the top UIScrollView has a delegate attached to it that gets notified when the contentOffset changes. That delegate, in turn, programatically sets the contentOffset of the background scroller, multiplied against a constant to slow the scroll down relative to the foreground. So, for instance, you might have something like:

// Defined as part of the delegate for the foreground UIScrollView
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    UIScrollView* scroll_view(static_cast<UIScrollView*>(bkg_scroller_m.view));
    CGPoint       offset(scrollView.contentOffset);

    offset.x = offset.x / 3;
    offset.y = offset.y / 3;

    // Scroll the background scroll view by some smaller offset
    scroll_view.contentOffset = offset;
}

這篇關于在 UIScrollView 上以不同的速度滾動背景的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

how to set scrollview content size in swift 3.0(如何在 swift 3.0 中設置滾動視圖內容大小)
Stop a UITableView from automatically scrolling(阻止 UITableView 自動滾動)
iOS UIScrollView Lazy Loading(iOS UIScrollView 延遲加載)
using iOS 6.0 SDK and building for iOS 5 Target causes UIScrollView setMinimumZoomScale to fail when running on iOS 5 simulator(在 iOS 5 模擬器上運行時,使用 iOS 6.0 SDK 并為 iOS 5 Target 構建會導致 UIScrollView setMinimumZ
Create partial-screen UIPageViewController programmatically(以編程方式創建部分屏幕 UIPageViewController)
how to make an ImageView zoomable with or without ScrollView.?(如何使用或不使用 ScrollView 使 ImageView 可縮放?)
主站蜘蛛池模板: 免费一级淫片aaa片毛片a级 | 久久久网 | 中文在线一区二区 | 黄色一级毛片 | 免费av播放 | 成人免费观看男女羞羞视频 | 国产区精品 | 91欧美精品成人综合在线观看 | 九色av| 精品日韩一区 | 亚洲高清成人在线 | 久久久国产精品网站 | 日韩一区二区三区在线视频 | 欧美日韩国产一区二区 | 色综合久久伊人 | 在线播放一区 | 一级片免费视频 | 狠狠干夜夜草 | 美女张开腿露出尿口 | 国产成人精品免高潮在线观看 | 欧美亚洲一区二区三区 | 国产一区二区三区四区hd | 欧美一区二区三区国产 | 国产成人精品一区二区三区在线 | 一区二区中文字幕 | 国产亚洲一区二区三区在线观看 | 久久精品一区二区三区四区 | 99re视频这里只有精品 | 精品久久久久久 | 国产日产精品一区二区三区四区 | 激情av免费看 | 伊人免费观看视频 | 午夜视频免费在线观看 | 亚洲精品久久久久久宅男 | 久久99深爱久久99精品 | 欧美综合一区二区三区 | 成人影院网站ww555久久精品 | 韩日中文字幕 | 国产91久久久久久久免费 | 国产精品区一区二区三区 | 欧美一极视频 |