Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/klop/KLParallaxView
KLParallaxView is a UIView subclass that imitates Apple TV's parallax effect, written in Objective-C.
https://github.com/klop/KLParallaxView
Last synced: 2 months ago
JSON representation
KLParallaxView is a UIView subclass that imitates Apple TV's parallax effect, written in Objective-C.
- Host: GitHub
- URL: https://github.com/klop/KLParallaxView
- Owner: klop
- License: mit
- Created: 2015-11-10T04:12:31.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-12-31T20:54:28.000Z (about 8 years ago)
- Last Synced: 2024-10-31T16:19:29.607Z (3 months ago)
- Language: Objective-C
- Homepage:
- Size: 3.93 MB
- Stars: 292
- Watchers: 12
- Forks: 34
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- Awesome-Mobile-UI - KLParallaxView - C | ![KLParallaxView](resources/KLParallaxView.gif) | (ALL)
README
# KLParallaxView
`KLParallaxView` is a `UIView` subclass that imitates [Apple TV's parallax effect](https://www.youtube.com/watch?v=Py21jv6kCnI), written in Objective-C, based on the similar [MPParallaxView](https://github.com/DroidsOnRoids/MPParallaxView) Swift implementation.
![KLParallaxView](http://i.imgur.com/xQHfm5x.gif)
## Installation
`KLParallaxView` is available through CocoaPods. To install it, simply add the following line to your Podfile:
```
pod "KLParallaxView"
```
## Example ProjectTo run the example project, clone the repo and use the workspace in the Example directory, or alternatively run `pod try "KLParallaxView"` and run the example target.
## Usage
`KLParallaxView` is initialized with an array of subviews whose ordering reflects their positioning in a view hierarchy i.e. `firstObject` is the bottommost view while `lastObject` is the topmost. By default, `KLParallaxView` controls each subview's movement during the parallax effect by the value of their `tag` property.
```Objective-C
#import "ViewController.h"
#import "KLParallaxView.h"@interface ViewController ()
@property (strong, nonatomic) KLParallaxView *parallaxView;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];UIImageView *imageView1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"1"]];
imageView1.tag = 0;
UIImageView *imageView2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"2"]];
imageView2.tag = 11;
UIImageView *imageView3 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"3"]];
imageView3.tag = 2;
NSArray *subviews = @[ imageView1, imageView2, imageView3 ];
self.parallaxView = [[KLParallaxView alloc] initWithFrame:self.view.bounds subviews:subviews];
[self.view addSubview:self.parallaxView];
}
```## Configuration
### Parallax settings
Set a subview's `tag` to control how much it moves.
```Objective-C
UIImageView *subview = ...
subview.tag = 3;
```
Use the subviews' positions in the view hierachy rather than their `tag` property.
```Objective-C
self.parallaxView.basedOnHierachy = YES;
```
Multiply the parallax effect on all views by a given factor.
```Objective-C
self.parallaxView.parallaxMultiplier = 2.5;
```
Multiply the zoom effect on all views by a given factor.
```Objective-C
self.parallaxView.zoomMultiplier = 1.5;
```
### Glow settingsToggle the glowing effect that follows touches.
```Objective-C
self.parallaxView.glows = NO;
```
Change the glow's color.
```Objective-C
self.parallaxView.glowColor = [UIColor aqua];
```
### Shadow settingsChange the shadow opacity.
```Objective-C
self.parallaxView.shadowOpacity = 0.3;
```
Change the shadow radius for when the view is not animating.
```Objective-C
self.parallaxView.initalShadowRadius = 3.5;
```
Change the shadow radius for when the view is animating.
```Objective-C
self.parallaxView.finalShadowRadius = 9.5;
```
Change the color of the shadow.
```Objective-C
self.parallaxView.shadowColor = [UIColor cerulean];
```
### OtherSet the view's corner radius.
```Objective-C
self.parallaxView.cornerRadius = 5;
```
## AssetsTaken from [MPParallaxView](https://github.com/DroidsOnRoids/MPParallaxView): Thanks [Konstantine Trundayev](https://dribbble.com/k0t) for Interstellar assets!
## License
KLParallaxView is available under the MIT license. See the LICENSE file for more info.