Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
1,313 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// NDIntroPageView.h | ||
// NDParallaxIntroView | ||
// | ||
// Created by Simon Wicha on 17/04/2016. | ||
// Copyright © 2016 Simon Wicha. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface NDIntroPageView : UIView | ||
|
||
@property (strong, nonatomic) IBOutlet UIImageView *imageView; | ||
@property (strong, nonatomic) IBOutlet UILabel *titlelabel; | ||
@property (strong, nonatomic) IBOutlet UILabel *descriptionLabel; | ||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *imageHorizontalConstraint; | ||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *titleLabelHeightConstraint; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// ABCIntroPageView.m | ||
// Gratitude | ||
// | ||
// Created by Simon Wicha on 17/04/2016. | ||
// Copyright © 2016 Simon Wicha. All rights reserved. | ||
// | ||
|
||
#import "NDIntroPageView.h" | ||
|
||
@implementation NDIntroPageView | ||
|
||
- (void)initialize{ | ||
self.backgroundColor = [UIColor clearColor]; | ||
} | ||
|
||
- (id)initWithCoder:(NSCoder *)aCoder{ | ||
if(self = [super initWithCoder:aCoder]){ | ||
[self initialize]; | ||
} | ||
return self; | ||
} | ||
|
||
- (id)initWithFrame:(CGRect)rect{ | ||
if(self = [super initWithFrame:rect]){ | ||
[self initialize]; | ||
} | ||
return self; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="8191" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES"> | ||
<dependencies> | ||
<deployment identifier="iOS"/> | ||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/> | ||
</dependencies> | ||
<objects> | ||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"> | ||
<connections> | ||
<outlet property="imageView" destination="VAK-5f-bEj" id="feV-tZ-g4H"/> | ||
<outlet property="titlelabel" destination="cbc-So-i87" id="w5y-bP-nSN"/> | ||
</connections> | ||
</placeholder> | ||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> | ||
<view contentMode="scaleToFill" id="iN0-l3-epB" customClass="NDIntroPageView"> | ||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/> | ||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | ||
<subviews> | ||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="TitleLabel" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="cbc-So-i87"> | ||
<rect key="frame" x="20" y="250" width="560" height="80"/> | ||
<animations/> | ||
<constraints> | ||
<constraint firstAttribute="height" constant="80" id="FCz-kH-MNV"/> | ||
</constraints> | ||
<fontDescription key="fontDescription" name="TrebuchetMS-Bold" family="Trebuchet MS" pointSize="24"/> | ||
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> | ||
<nil key="highlightedColor"/> | ||
</label> | ||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="DescriptionLabel" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="Vkc-vv-81W"> | ||
<rect key="frame" x="20" y="350" width="560" height="160"/> | ||
<animations/> | ||
<fontDescription key="fontDescription" name="TrebuchetMS-Bold" family="Trebuchet MS" pointSize="17"/> | ||
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> | ||
<nil key="highlightedColor"/> | ||
</label> | ||
<imageView userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="VAK-5f-bEj"> | ||
<rect key="frame" x="20" y="120" width="560" height="100"/> | ||
<animations/> | ||
<constraints> | ||
<constraint firstAttribute="height" constant="100" id="hmh-sX-819"/> | ||
</constraints> | ||
</imageView> | ||
</subviews> | ||
<animations/> | ||
<color key="backgroundColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/> | ||
<constraints> | ||
<constraint firstItem="Vkc-vv-81W" firstAttribute="top" secondItem="cbc-So-i87" secondAttribute="bottom" constant="20" id="5eU-Ac-PK3"/> | ||
<constraint firstItem="VAK-5f-bEj" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="centerY" constant="-130" id="EII-5U-v0y"/> | ||
<constraint firstItem="Vkc-vv-81W" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" id="H7J-jA-5Dm"/> | ||
<constraint firstItem="cbc-So-i87" firstAttribute="top" secondItem="VAK-5f-bEj" secondAttribute="bottom" constant="30" id="IiJ-Ja-oLT"/> | ||
<constraint firstAttribute="trailing" secondItem="Vkc-vv-81W" secondAttribute="trailing" constant="20" id="W0a-YR-7AK"/> | ||
<constraint firstItem="cbc-So-i87" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" id="W8V-L2-Obw"/> | ||
<constraint firstAttribute="trailing" secondItem="VAK-5f-bEj" secondAttribute="trailing" constant="20" id="eeo-Bx-Cof"/> | ||
<constraint firstAttribute="bottom" secondItem="Vkc-vv-81W" secondAttribute="bottom" constant="90" id="fdz-GH-iut"/> | ||
<constraint firstAttribute="trailing" secondItem="cbc-So-i87" secondAttribute="trailing" constant="20" id="uI9-6b-SVo"/> | ||
<constraint firstItem="VAK-5f-bEj" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" id="ubI-NN-GNI"/> | ||
</constraints> | ||
<connections> | ||
<outlet property="descriptionLabel" destination="Vkc-vv-81W" id="elZ-7r-nK1"/> | ||
<outlet property="imageHorizontalConstraint" destination="EII-5U-v0y" id="sUu-g9-CDg"/> | ||
<outlet property="imageView" destination="VAK-5f-bEj" id="SVy-X1-yUa"/> | ||
<outlet property="titleLabelHeightConstraint" destination="FCz-kH-MNV" id="gin-bs-k0H"/> | ||
<outlet property="titlelabel" destination="cbc-So-i87" id="zKd-yE-dvy"/> | ||
</connections> | ||
</view> | ||
</objects> | ||
</document> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// | ||
// NDIntroPageView.h | ||
// NDParallaxIntroView | ||
// | ||
// Created by Simon Wicha on 17/04/2016. | ||
// Copyright © 2016 Simon Wicha. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@protocol NDIntroViewDelegate <NSObject> | ||
|
||
-(void)onDoneButtonPressed; | ||
|
||
@end | ||
|
||
@interface NDIntroView : UIView | ||
@property id<NDIntroViewDelegate> delegate; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
// | ||
// NDIntroPageView.m | ||
// NDParallaxIntroView | ||
// | ||
// Created by Simon Wicha on 17/04/2016. | ||
// Copyright © 2016 Simon Wicha. All rights reserved. | ||
// | ||
|
||
#import "NDIntroView.h" | ||
#import "NDIntroPageView.h" | ||
|
||
@interface NDIntroView () <UIScrollViewDelegate> | ||
@property (strong, nonatomic) UIScrollView *scrollView; | ||
@property (strong, nonatomic) UIScrollView *scrollViewBackgroundImage; | ||
@property (strong, nonatomic) UIPageControl *pageControl; | ||
@property (strong, nonatomic) UIButton *doneButton; | ||
|
||
@property (strong, nonatomic) IBOutlet NDIntroPageView *viewOne; | ||
@property (strong, nonatomic) IBOutlet NDIntroPageView *viewTwo; | ||
@property (strong, nonatomic) IBOutlet NDIntroPageView *viewThree; | ||
@property (strong, nonatomic) IBOutlet NDIntroPageView *viewFour; | ||
|
||
|
||
@end | ||
|
||
@implementation NDIntroView | ||
|
||
- (instancetype)initWithFrame:(CGRect)frame{ | ||
self = [super initWithFrame:frame]; | ||
if(self){ | ||
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.scrollView.frame.size.width * 4, self.frame.size.height)]; | ||
[imageView setImage:[UIImage imageNamed:@"introBackgroundImage"]]; | ||
imageView.contentMode = UIViewContentModeLeft; | ||
[self.scrollViewBackgroundImage addSubview:imageView]; | ||
|
||
[self addSubview:self.scrollViewBackgroundImage]; | ||
[self addSubview:self.scrollView]; | ||
[self addSubview:self.pageControl]; | ||
|
||
[self.scrollView addSubview:self.viewOne]; | ||
[self.scrollView addSubview:self.viewTwo]; | ||
[self.scrollView addSubview:self.viewThree]; | ||
[self.scrollView addSubview:self.viewFour]; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)scrollViewDidScroll:(UIScrollView *)scrollView { | ||
|
||
CGFloat pageWidth = CGRectGetWidth(self.bounds); | ||
CGFloat pageFraction = self.scrollView.contentOffset.x / pageWidth; | ||
self.pageControl.currentPage = roundf(pageFraction); | ||
[self.scrollViewBackgroundImage setContentOffset:CGPointMake(self.scrollView.contentOffset.x * 0.5f, self.scrollView.contentOffset.y) animated:NO]; | ||
} | ||
|
||
- (NSBundle *)podBundle { | ||
return [NSBundle bundleForClass:[self classForCoder]];; | ||
} | ||
|
||
-(UIView *)viewOne { | ||
_viewOne = [[[self podBundle] loadNibNamed:@"NDIntroPageView" owner:nil options:nil] lastObject]; | ||
_viewOne.frame = self.frame; | ||
_viewOne.imageView.image = [[UIImage imageNamed:@"logo"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; | ||
_viewOne.titlelabel.text = @"Want to live happier?"; | ||
_viewOne.descriptionLabel.text = @"Ready for a new life hack backed up by science? Learn to appreciate the good things around you with this beautiful app!"; | ||
return _viewOne; | ||
|
||
} | ||
|
||
-(UIView *)viewTwo { | ||
CGFloat originWidth = self.frame.size.width; | ||
CGFloat originHeight = self.frame.size.height; | ||
_viewTwo = [[[self podBundle] loadNibNamed:@"NDIntroPageView" owner:nil options:nil] lastObject]; | ||
_viewTwo.frame = CGRectMake(originWidth, 0, originWidth, originHeight); | ||
_viewTwo.imageView.image = [[UIImage imageNamed:@"science"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; | ||
_viewTwo.titlelabel.text = @"Backed up by science"; | ||
_viewTwo.descriptionLabel.text = @"Researchers suggest that one of the most contributing factors to overall happiness is expressed gratitude."; | ||
return _viewTwo; | ||
|
||
} | ||
|
||
-(UIView *)viewThree{ | ||
CGFloat originWidth = self.frame.size.width; | ||
CGFloat originHeight = self.frame.size.height; | ||
_viewThree = [[[self podBundle] loadNibNamed:@"NDIntroPageView" owner:nil options:nil] lastObject]; | ||
_viewThree.frame = CGRectMake(originWidth*2, 0, originWidth, originHeight); | ||
_viewThree.imageView.image = [[UIImage imageNamed:@"what"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; | ||
_viewThree.titlelabel.text = @"How does this App help?"; | ||
_viewThree.descriptionLabel.text = @"The App encourages you to think about anything you felt grateful for (e.g. things, people, relationships, experiences, talents, circumstances, nature, cultural aspects like art or music, ...) and to write it down on a daily basis."; | ||
return _viewThree; | ||
|
||
} | ||
|
||
-(UIView *)viewFour { | ||
CGFloat originWidth = self.frame.size.width; | ||
CGFloat originHeight = self.frame.size.height; | ||
_viewFour = [[[self podBundle] loadNibNamed:@"NDIntroPageView" owner:nil options:nil] lastObject]; | ||
_viewFour.frame = CGRectMake(originWidth*3, 0, originWidth, originHeight); | ||
_viewFour.imageView.image = [[UIImage imageNamed:@"titleWhite"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; | ||
_viewFour.imageHorizontalConstraint.constant = -40.f; | ||
_viewFour.titleLabelHeightConstraint.constant = 0.f; | ||
_viewFour.titlelabel.text = @""; | ||
_viewFour.descriptionLabel.text = @"So let's start your happier life!"; | ||
[_viewFour addSubview:self.doneButton]; | ||
return _viewFour; | ||
|
||
} | ||
|
||
-(UIScrollView *)scrollView { | ||
if (!_scrollView) { | ||
_scrollView = [[UIScrollView alloc] initWithFrame:self.frame]; | ||
[_scrollView setDelegate:self]; | ||
[_scrollView setPagingEnabled:YES]; | ||
[_scrollView setContentSize:CGSizeMake(self.frame.size.width*4, self.scrollView.frame.size.height)]; | ||
_scrollView.showsHorizontalScrollIndicator = NO; | ||
[self.scrollView setContentOffset:CGPointMake(0, 0) animated:YES]; | ||
} | ||
return _scrollView; | ||
} | ||
|
||
-(UIScrollView *)scrollViewBackgroundImage { | ||
if (!_scrollViewBackgroundImage) { | ||
_scrollViewBackgroundImage = [[UIScrollView alloc] initWithFrame:self.frame]; | ||
[_scrollViewBackgroundImage setDelegate:self]; | ||
[_scrollViewBackgroundImage setPagingEnabled:YES]; | ||
_scrollViewBackgroundImage.userInteractionEnabled = NO; | ||
[_scrollViewBackgroundImage setContentSize:CGSizeMake(self.frame.size.width*4, self.scrollView.frame.size.height)]; | ||
_scrollViewBackgroundImage.showsHorizontalScrollIndicator = NO; | ||
[self.scrollViewBackgroundImage setContentOffset:CGPointMake(0, 0) animated:YES]; | ||
} | ||
return _scrollViewBackgroundImage; | ||
} | ||
|
||
-(UIPageControl *)pageControl { | ||
if (!_pageControl) { | ||
_pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0, self.frame.size.height-80, self.frame.size.width, 10)]; | ||
[_pageControl setCurrentPageIndicatorTintColor:[UIColor whiteColor]]; | ||
[_pageControl setNumberOfPages:4]; | ||
} | ||
return _pageControl; | ||
} | ||
|
||
-(UIButton *)doneButton { | ||
if (!_doneButton) { | ||
_doneButton = [[UIButton alloc] initWithFrame:CGRectMake(20, self.frame.size.height-60, self.frame.size.width - 40, 40)]; | ||
_doneButton.layer.cornerRadius = 5.f; | ||
[_doneButton setTintColor:[UIColor whiteColor]]; | ||
[_doneButton setTitle:@"Let's Go!" forState:UIControlStateNormal]; | ||
[_doneButton.titleLabel setFont:[UIFont fontWithName:@"TrebuchetMS" size:18.0]]; | ||
[_doneButton setBackgroundColor:[UIColor lightGrayColor]]; | ||
[_doneButton addTarget:self.delegate action:@selector(onDoneButtonPressed) forControlEvents:UIControlEventTouchUpInside]; | ||
} | ||
return _doneButton; | ||
} | ||
|
||
@end |
19 changes: 19 additions & 0 deletions
19
NDParallaxIntroViewExample/NDParallaxIntroView/NDIntroPageView.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// NDIntroPageView.h | ||
// NDParallaxIntroView | ||
// | ||
// Created by Simon Wicha on 17/04/2016. | ||
// Copyright © 2016 Simon Wicha. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface NDIntroPageView : UIView | ||
|
||
@property (strong, nonatomic) IBOutlet UIImageView *imageView; | ||
@property (strong, nonatomic) IBOutlet UILabel *titlelabel; | ||
@property (strong, nonatomic) IBOutlet UILabel *descriptionLabel; | ||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *imageHorizontalConstraint; | ||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *titleLabelHeightConstraint; | ||
|
||
@end |
31 changes: 31 additions & 0 deletions
31
NDParallaxIntroViewExample/NDParallaxIntroView/NDIntroPageView.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// NDIntroPageView.m | ||
// NDParallaxIntroView | ||
// | ||
// Created by Simon Wicha on 17/04/2016. | ||
// Copyright © 2016 Simon Wicha. All rights reserved. | ||
// | ||
|
||
#import "NDIntroPageView.h" | ||
|
||
@implementation NDIntroPageView | ||
|
||
- (void)initialize{ | ||
self.backgroundColor = [UIColor clearColor]; | ||
} | ||
|
||
- (id)initWithCoder:(NSCoder *)aCoder{ | ||
if(self = [super initWithCoder:aCoder]){ | ||
[self initialize]; | ||
} | ||
return self; | ||
} | ||
|
||
- (id)initWithFrame:(CGRect)rect{ | ||
if(self = [super initWithFrame:rect]){ | ||
[self initialize]; | ||
} | ||
return self; | ||
} | ||
|
||
@end |
Oops, something went wrong.