Skip to content

Commit 31aae18

Browse files
committed
Initial commit.
0 parents  commit 31aae18

32 files changed

+2019
-0
lines changed

.gitignore

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Xcode
2+
.DS_Store
3+
build/
4+
*.pbxuser
5+
!default.pbxuser
6+
*.mode1v3
7+
!default.mode1v3
8+
*.mode2v3
9+
!default.mode2v3
10+
*.perspectivev3
11+
!default.perspectivev3
12+
*.xcworkspace
13+
!default.xcworkspace
14+
xcuserdata
15+
profile
16+
*.moved-aside
17+
DerivedData
18+
.idea/

Demo/SCPageViewController.xcodeproj/project.pbxproj

+383
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// UIColor+RandomColors.h
3+
// SCPageViewController
4+
//
5+
// Created by Stefan Ceriu on 15/02/2014.
6+
// Copyright (c) 2014 Stefan Ceriu. All rights reserved.
7+
//
8+
9+
@interface UIColor (RandomColors)
10+
11+
+ (UIColor *)randomColor;
12+
13+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// UIColor+RandomColors.m
3+
// SCPageViewController
4+
//
5+
// Created by Stefan Ceriu on 15/02/2014.
6+
// Copyright (c) 2014 Stefan Ceriu. All rights reserved.
7+
//
8+
9+
#import "UIColor+RandomColors.h"
10+
11+
@implementation UIColor (RandomColors)
12+
13+
+ (UIColor *)randomColor
14+
{
15+
CGFloat hue = ( arc4random() % 256 / 256.0 ); // 0.0 to 1.0
16+
CGFloat saturation = ( arc4random() % 128 / 256.0 ) + 0.5; // 0.5 to 1.0, away from white
17+
CGFloat brightness = ( arc4random() % 128 / 256.0 ) + 0.5; // 0.5 to 1.0, away from black
18+
return [UIColor colorWithHue:hue saturation:saturation brightness:brightness alpha:1];
19+
}
20+
21+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//
2+
// UIView+Shadows.h
3+
// SCPageViewController
4+
//
5+
// Created by Stefan Ceriu on 15/02/2014.
6+
// Copyright (c) 2014 Stefan Ceriu. All rights reserved.
7+
//
8+
9+
typedef enum {
10+
SCShadowEdgeNone = 0,
11+
SCShadowEdgeTop = 1 << 0,
12+
SCShadowEdgeLeft = 1 << 1,
13+
SCShadowEdgeBottom = 1 << 2,
14+
SCShadowEdgeRight = 1 << 3,
15+
SCShadowEdgeAll = SCShadowEdgeTop | SCShadowEdgeLeft | SCShadowEdgeBottom | SCShadowEdgeRight
16+
} SCShadowEdge;
17+
18+
@interface UIView (Shadows)
19+
20+
- (void)castShadowWithPosition:(SCShadowEdge)edge;
21+
22+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//
2+
// UIView+Shadows.m
3+
// SCPageViewController
4+
//
5+
// Created by Stefan Ceriu on 15/02/2014.
6+
// Copyright (c) 2014 Stefan Ceriu. All rights reserved.
7+
//
8+
9+
#import "UIView+Shadows.h"
10+
#import <QuartzCore/QuartzCore.h>
11+
12+
static const CGFloat shadowSize = 10;
13+
14+
@implementation UIView (Shadows)
15+
16+
- (void)castShadowWithPosition:(SCShadowEdge)position;
17+
{
18+
CGRect shadowRect = self.bounds;
19+
20+
if(position & SCShadowEdgeTop) {
21+
shadowRect.origin.y -= shadowSize;
22+
shadowRect.size.height += shadowSize;
23+
}
24+
25+
if(position & SCShadowEdgeLeft) {
26+
shadowRect.origin.x -= shadowSize;
27+
shadowRect.size.width += shadowSize;
28+
}
29+
30+
if(position & SCShadowEdgeBottom) {
31+
shadowRect.size.height += shadowSize;
32+
}
33+
34+
if(position & SCShadowEdgeRight) {
35+
shadowRect.size.width += shadowSize;
36+
}
37+
38+
self.layer.masksToBounds = NO;
39+
self.layer.shadowRadius = 5;
40+
self.layer.shadowOffset = CGSizeZero;
41+
self.layer.shadowOpacity = 0.25;
42+
43+
self.layer.shadowPath = [UIBezierPath bezierPathWithRect:shadowRect].CGPath;
44+
}
45+
46+
@end
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// SCAppDelegate.h
3+
// SCPageViewController
4+
//
5+
// Created by Stefan Ceriu on 10/02/2014.
6+
// Copyright (c) 2014 Stefan Ceriu. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
11+
@interface SCAppDelegate : UIResponder <UIApplicationDelegate>
12+
13+
@property (strong, nonatomic) UIWindow *window;
14+
15+
@end
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//
2+
// SCAppDelegate.m
3+
// SCPageViewController
4+
//
5+
// Created by Stefan Ceriu on 10/02/2014.
6+
// Copyright (c) 2014 Stefan Ceriu. All rights reserved.
7+
//
8+
9+
#import "SCAppDelegate.h"
10+
#import "SCRootViewController.h"
11+
12+
@implementation SCAppDelegate
13+
14+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
15+
{
16+
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
17+
self.window.rootViewController = [[SCRootViewController alloc] initWithNibName:NSStringFromClass([SCRootViewController class]) bundle:nil];
18+
[self.window makeKeyAndVisible];
19+
return YES;
20+
}
21+
22+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//
2+
// SCMainViewController.h
3+
// SCPageViewController
4+
//
5+
// Created by Stefan Ceriu on 15/02/2014.
6+
// Copyright (c) 2014 Stefan Ceriu. All rights reserved.
7+
//
8+
9+
typedef enum {
10+
SCPageLayouterTypePlain,
11+
SCPageLayouterTypeSliding,
12+
SCPageLayouterTypeParallax,
13+
SCPageLayouterTypeCount
14+
} SCPageLayouterType;
15+
16+
@protocol SCMainViewControllerDelegate;
17+
18+
@interface SCMainViewController : UIViewController
19+
20+
@property (nonatomic, readonly) UILabel *pageNumberLabel;
21+
@property (nonatomic, readonly) UILabel *visiblePercentageLabel;
22+
23+
@property (nonatomic, weak) IBOutlet id<SCMainViewControllerDelegate> delegate;
24+
25+
@end
26+
27+
@protocol SCMainViewControllerDelegate <NSObject>
28+
29+
- (void)mainViewController:(SCMainViewController *)mainViewController
30+
didSelectLayouter:(SCPageLayouterType)type;
31+
32+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
//
2+
// SCMainViewController.m
3+
// SCPageViewController
4+
//
5+
// Created by Stefan Ceriu on 15/02/2014.
6+
// Copyright (c) 2014 Stefan Ceriu. All rights reserved.
7+
//
8+
9+
#import "SCMainViewController.h"
10+
11+
@interface SCMainViewController () <UITableViewDataSource, UITableViewDelegate>
12+
13+
@property (nonatomic, weak) IBOutlet UILabel *pageNumberLabel;
14+
@property (nonatomic, weak) IBOutlet UILabel *visiblePercentageLabel;
15+
16+
@end
17+
18+
@implementation SCMainViewController
19+
20+
#pragma mark - UITableViewDataSource
21+
22+
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
23+
{
24+
return SCPageLayouterTypeCount;
25+
}
26+
27+
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
28+
{
29+
static NSString *identifier = @"CellIdentifier";
30+
31+
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
32+
33+
if(cell == nil) {
34+
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
35+
}
36+
37+
static NSDictionary *typeToString;
38+
static dispatch_once_t onceToken;
39+
dispatch_once(&onceToken, ^{
40+
typeToString = (@{
41+
@(SCPageLayouterTypePlain) : @"Plain",
42+
@(SCPageLayouterTypeSliding) : @"Sliding",
43+
@(SCPageLayouterTypeParallax) : @"Parallax",
44+
});
45+
});
46+
47+
[cell.textLabel setText:typeToString[@(indexPath.row)]];
48+
[cell.textLabel setFont:[UIFont fontWithName:@"Menlo" size:18.0f]];
49+
[cell setBackgroundColor:[UIColor colorWithWhite:1.0f alpha:0.20f]];
50+
51+
return cell;
52+
}
53+
54+
#pragma mark - UITableViewDelegate
55+
56+
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
57+
{
58+
if([self.delegate respondsToSelector:@selector(mainViewController:didSelectLayouter:)]) {
59+
[self.delegate mainViewController:self didSelectLayouter:indexPath.row];
60+
}
61+
}
62+
63+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="3.0" toolsVersion="4514" systemVersion="13B42" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none">
3+
<dependencies>
4+
<deployment defaultVersion="1280" identifier="iOS"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3747"/>
6+
</dependencies>
7+
<objects>
8+
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="SCMainViewController">
9+
<connections>
10+
<outlet property="pageNumberLabel" destination="hMk-8Z-eAU" id="B5t-mk-kIy"/>
11+
<outlet property="view" destination="2" id="3"/>
12+
<outlet property="visiblePercentageLabel" destination="wll-YW-rSq" id="RuX-mW-dZ5"/>
13+
</connections>
14+
</placeholder>
15+
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
16+
<view clipsSubviews="YES" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="2">
17+
<rect key="frame" x="0.0" y="0.0" width="1024" height="768"/>
18+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
19+
<subviews>
20+
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="colorful_umbrellas.jpg" id="9KI-93-5Hu">
21+
<rect key="frame" x="0.0" y="0.0" width="1024" height="768"/>
22+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
23+
</imageView>
24+
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="hMk-8Z-eAU" userLabel="Page Number Label">
25+
<rect key="frame" x="20" y="20" width="272" height="47"/>
26+
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
27+
<fontDescription key="fontDescription" name="Menlo-Bold" family="Menlo" pointSize="36"/>
28+
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
29+
<nil key="highlightedColor"/>
30+
<color key="shadowColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
31+
<size key="shadowOffset" width="0.0" height="1"/>
32+
</label>
33+
<tableView clipsSubviews="YES" contentMode="scaleToFill" bounces="NO" alwaysBounceVertical="YES" style="plain" separatorStyle="none" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="5">
34+
<rect key="frame" x="362" y="295" width="300" height="178"/>
35+
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
36+
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
37+
<color key="separatorColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
38+
<connections>
39+
<outlet property="dataSource" destination="-1" id="6"/>
40+
<outlet property="delegate" destination="-1" id="7"/>
41+
</connections>
42+
</tableView>
43+
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="50%" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="wll-YW-rSq" userLabel="Visible percentage label">
44+
<rect key="frame" x="735" y="701" width="269" height="47"/>
45+
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
46+
<fontDescription key="fontDescription" name="Menlo-Bold" family="Menlo" pointSize="36"/>
47+
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
48+
<nil key="highlightedColor"/>
49+
<color key="shadowColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
50+
<size key="shadowOffset" width="0.0" height="1"/>
51+
</label>
52+
</subviews>
53+
<color key="backgroundColor" white="0.80200982860000003" alpha="1" colorSpace="calibratedWhite"/>
54+
<simulatedOrientationMetrics key="simulatedOrientationMetrics" orientation="landscapeRight"/>
55+
</view>
56+
</objects>
57+
<resources>
58+
<image name="colorful_umbrellas.jpg" width="1024" height="768"/>
59+
</resources>
60+
</document>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>en</string>
7+
<key>CFBundleDisplayName</key>
8+
<string>${PRODUCT_NAME}</string>
9+
<key>CFBundleExecutable</key>
10+
<string>${EXECUTABLE_NAME}</string>
11+
<key>CFBundleIdentifier</key>
12+
<string>com.stefanceriu.${PRODUCT_NAME:rfc1034identifier}</string>
13+
<key>CFBundleInfoDictionaryVersion</key>
14+
<string>6.0</string>
15+
<key>CFBundleName</key>
16+
<string>${PRODUCT_NAME}</string>
17+
<key>CFBundlePackageType</key>
18+
<string>APPL</string>
19+
<key>CFBundleShortVersionString</key>
20+
<string>1.0</string>
21+
<key>CFBundleSignature</key>
22+
<string>????</string>
23+
<key>CFBundleVersion</key>
24+
<string>1.0</string>
25+
<key>LSRequiresIPhoneOS</key>
26+
<true/>
27+
<key>UIRequiredDeviceCapabilities</key>
28+
<array>
29+
<string>armv7</string>
30+
</array>
31+
<key>UISupportedInterfaceOrientations~ipad</key>
32+
<array>
33+
<string>UIInterfaceOrientationLandscapeRight</string>
34+
<string>UIInterfaceOrientationLandscapeLeft</string>
35+
</array>
36+
</dict>
37+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// Prefix header
3+
//
4+
// The contents of this file are implicitly included at the beginning of every source file.
5+
//
6+
7+
#import <Availability.h>
8+
9+
#ifndef __IPHONE_5_0
10+
#warning "This project uses features only available in iOS SDK 5.0 and later."
11+
#endif
12+
13+
#ifdef __OBJC__
14+
#import <UIKit/UIKit.h>
15+
#import <Foundation/Foundation.h>
16+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//
2+
// SCRootViewController.h
3+
// SCPageViewController
4+
//
5+
// Created by Stefan Ceriu on 15/02/2014.
6+
// Copyright (c) 2014 Stefan Ceriu. All rights reserved.
7+
//
8+
9+
@interface SCRootViewController : UIViewController
10+
11+
@end

0 commit comments

Comments
 (0)