Skip to content
프로젝트

소개

KLParallaxView is a UIView subclass that imitates Apple TV's parallax effect, written in Objective-C.

웹 및 앱 개발

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

KLParallaxView

KLParallaxView is a UIView subclass that imitates Apple TV's parallax effect, written in Objective-C, based on the similar MPParallaxView Swift implementation.

KLParallaxView

Installation

KLParallaxView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "KLParallaxView"

Example Project

To 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.


#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.

UIImageView *subview = ...
subview.tag = 3;

Use the subviews' positions in the view hierachy rather than their tag property.

self.parallaxView.basedOnHierachy = YES;

Multiply the parallax effect on all views by a given factor.

self.parallaxView.parallaxMultiplier = 2.5;

Multiply the zoom effect on all views by a given factor.

self.parallaxView.zoomMultiplier = 1.5;

Glow settings

Toggle the glowing effect that follows touches.

self.parallaxView.glows = NO;

Change the glow's color.

self.parallaxView.glowColor = [UIColor aqua];

Shadow settings

Change the shadow opacity.

self.parallaxView.shadowOpacity = 0.3;

Change the shadow radius for when the view is not animating.

self.parallaxView.initalShadowRadius = 3.5;

Change the shadow radius for when the view is animating.

self.parallaxView.finalShadowRadius = 9.5;

Change the color of the shadow.

self.parallaxView.shadowColor = [UIColor cerulean];

Other

Set the view's corner radius.

self.parallaxView.cornerRadius = 5;

Assets

Taken from MPParallaxView: Thanks Konstantine Trundayev for Interstellar assets!

License

KLParallaxView is available under the MIT license. See the LICENSE file for more info.

관련 프로젝트 살펴보기

불러오는 중…