久久久久久久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 可縮放?)
主站蜘蛛池模板: 国产精品国产成人国产三级 | 欧美色综合天天久久综合精品 | 国产分类视频 | 亚洲中字在线 | 欧美日韩在线不卡 | 97超碰免费 | 色综合一区二区 | 日本中文字幕视频 | 精品婷婷| 在线播放一区二区三区 | 欧美在线一区二区三区 | 毛片一区二区 | 玖玖免费| 久久精品欧美一区二区三区麻豆 | 国产黄色大片 | 自拍中文字幕 | 久久久www成人免费精品 | 日本一区二区三区免费观看 | www.av在线| 久久国内精品 | 欧美性生交大片免费 | 精品二区 | 青娱乐一区二区 | 中文视频在线 | 久久精品免费 | 久久久tv | 日韩乱码在线 | 伦理二区| 高清一区二区三区 | 国产不卡在线观看 | 国产高清视频 | 伊人久久综合影院 | 亚洲成人中文字幕 | 欧美1区 | 伊人网99| 一区二区三区在线电影 | 日韩有码一区 | 久久国产精品-国产精品 | 一区二区三区四区免费观看 | 色综合一区 | 中文字幕专区 |