Inspired by Yahoo Weather App, this easy to use view replicates the look and feel
_
This is a view for you to either use as-is or modify the source. The view comes loaded with the ability to:
Background:
I have been a big fan of Yahoo! weather app. I highly respect the work they have done. I wanted to replicate and also generalize the approach for anyone to use and/or study. This was not associated with Yahoo! No source was lifted from Yahoo! So there will be a few subtle differences between BTGlassScrollView and Yahoo! weather app. For example, this view is built to stay under one navigation bar which in turns allows for "swipe to back" on iOS7.
Implementation:
The view is a subclass of a UIView. It contains 2 scrollViews, background and foreground. backgroundScrollView consists of 2 imageviews, normal and blurred. The alpha of the blurred one changes as the background scrolls. And the background scrolls as the foreground scrolls (at a different rate). The foregroundScrollView consists of maskLayers (gradient) and the foregroundView (which is whatever you want it to be). Between foreground and background, 2 shadowsLayer is added on the top and bottom to give a better readability.
How to use (Simple Version):
BTGlassScrollView.h
- (id)initWithFrame:(CGRect)frame BackgroundImage:(UIImage *)backgroundImage blurredImage:(UIImage *)blurredImage viewDistanceFromBottom:(CGFloat)viewDistanceFromBottom foregroundView:(UIView *)foregroundView
and add it as subview to whereever you need it to bebackgroundImage
is essential, pick the right one makes all the differenceblurredImage
is not neccessary but you can provide your own customed oneviewDistanceFromBottom
is how much your foregroundView is visible from the bottom (like Yahoo! temperature)foregroundView
is your info view- (void)setTopLayoutGuideLength:(CGFloat)topLayoutGuideLength
where appropriate (Usually at viewWillLayoutSubviews
in your view controllerPlease view example project to get the idea of how to implement.
How to implement Yahoo! like horizontal Scroll:
To Be Added - it is in the example just not explained in words
Note:
The example provided are mix of 3 * 2 flavor. 3 ways to create viewController and 2 ways to implement the view. Uncomment the code in Appdelegate to see the different ways of creating ViewController and change the #define SIMPLE_SAMPLE
to see the two ways of implementing
3 ways to create viewController:
2 ways to implement the view
Example 2 Note
It is not without its bug. I would be very glad if someone can help fixing it
Known issues:
Copyright 2014 Byte
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.