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????)
相关问题
- Views base64 encoded blob in HTML with PHP
- How to get the background from multiple images by
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
相关文章
- UITableView dragging distance with UIRefreshContro
- Could I create “Call” button in HTML 5 IPhone appl
- Use savefig in Python with string and iterative in
- Unable to process app at this time due to a genera
- Where does this quality loss on Images come from?
- Specifying image dimensions in HTML vs CSS for pag
- How to insert pictures into each individual bar in
- How do you detect key up / key down events from a
You can easily do this by implementing scroll view did scroll with a UIImageView under it... You'll end up with something like this... with the backgroundImageView being a UIImageView added to the view before the subview... you can layer as much image views as you want without performance issues
For example you have multiple scrollviews, want them scroll difference speed. here is the modification code base on Salamatizm answer:
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 topUIScrollView
has a delegate attached to it that gets notified when thecontentOffset
changes. That delegate, in turn, programatically sets thecontentOffset
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:You can do it with CoreAnimation. You'll want to hook into the
scrollViewDidEndDragging:willDecelerate:
andscrollViewWillBeginDecelerating:
UIScrollViewDelegate methods. Then begin an Animation on your image by changing the center position. See this SO article for more on animations.