Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions MKCubeController.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,12 @@
49BBCFE01C598D650052F869 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0920;
LastUpgradeCheck = 1010;
ORGANIZATIONNAME = "Kevin Malkic";
TargetAttributes = {
49BBCFE81C598D650052F869 = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 1010;
};
};
};
Expand Down Expand Up @@ -156,12 +157,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down Expand Up @@ -212,12 +215,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down Expand Up @@ -269,7 +274,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -291,7 +296,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.kevinmalkic.MKCubeController;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
16 changes: 9 additions & 7 deletions MKCubeController/MKCubeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public class MKCubeViewController: UIViewController, UIScrollViewDelegate {
public weak var dataSource: MKCubeViewControllerDataSource?
public weak var delegate: MKCubeViewControllerDelegate?

public var focalLength: CGFloat = 500

private var controllers = [Int: UIViewController]()
private var scrollOffset: CGFloat = 0
private var previousOffset: CGFloat = 0
Expand Down Expand Up @@ -110,19 +112,19 @@ public class MKCubeViewController: UIViewController, UIScrollViewDelegate {
if animated {

let animation: CATransition = CATransition()
animation.type = kCATransitionFade
animation.type = CATransitionType.fade
scrollView.layer.add(animation, forKey: nil)
}

controller.view!.removeFromSuperview()
controller.removeFromParentViewController()
controller.removeFromParent()

if let newController = dataSource?.cubeController(cubeController: self, viewControllerAtIndex: index) {

controllers[index] = newController
newController.view.layer.isDoubleSided = false

addChildViewController(newController)
addChild(newController)
scrollView.addSubview(newController.view!)

newController.view.layer.transform = transform
Expand Down Expand Up @@ -175,7 +177,7 @@ public class MKCubeViewController: UIViewController, UIScrollViewDelegate {

controller.viewWillDisappear(false)
controller.view!.removeFromSuperview()
controller.removeFromParentViewController()
controller.removeFromParent()
controller.viewDidDisappear(false)
}

Expand Down Expand Up @@ -219,7 +221,7 @@ public class MKCubeViewController: UIViewController, UIScrollViewDelegate {

controller.view.autoresizingMask = []
controller.view.layer.isDoubleSided = false
addChildViewController(controller)
addChild(controller)
scrollView.addSubview(controller.view)
}

Expand All @@ -238,7 +240,7 @@ public class MKCubeViewController: UIViewController, UIScrollViewDelegate {

if angle != 0.0 {

transform.m34 = -1.0 / 500
transform.m34 = 1.0 / -focalLength
transform = CATransform3DTranslate(transform, 0, 0, -view.bounds.size.width / 2.0)
transform = CATransform3DRotate(transform, -CGFloat(angle), 0, 1, 0)
transform = CATransform3DTranslate(transform, 0, 0, view.bounds.size.width / 2.0)
Expand Down Expand Up @@ -292,7 +294,7 @@ public class MKCubeViewController: UIViewController, UIScrollViewDelegate {
if !visibleIndices.contains(index) {

controller.view!.removeFromSuperview()
controller.removeFromParentViewController()
controller.removeFromParent()
controllers.removeValue(forKey: index)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,12 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0920;
LastUpgradeCheck = 1010;
ORGANIZATIONNAME = "Kevin Malkic";
TargetAttributes = {
0A95A5041C5A342D00430543 = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 1010;
};
};
};
Expand Down Expand Up @@ -194,12 +195,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down Expand Up @@ -247,12 +250,14 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down Expand Up @@ -292,7 +297,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.ustwo.MKCubeControllerDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -306,7 +311,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.ustwo.MKCubeControllerDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down
3 changes: 2 additions & 1 deletion MKCubeControllerDemo/MKCubeControllerDemo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, MKCubeViewControllerDataS

var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

let controller = MKCubeViewController()
controller.focalLength = 1000
controller.dataSource = self
controller.wrapEnabled = true

Expand Down
61 changes: 38 additions & 23 deletions MKCubeControllerDemo/MKCubeControllerDemo/BlueViewController.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9531" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14460.15" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.9"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ViewController">
Expand All @@ -12,49 +17,59 @@
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="1">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Third Screen" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="e9P-CJ-qX9">
<rect key="frame" x="20" y="180" width="280" height="52"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Third Screen" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="e9P-CJ-qX9">
<rect key="frame" x="113" y="225" width="149" height="30"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="25"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Swipe right or left to move to the previous or next screens" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="3XM-Ym-byh">
<rect key="frame" x="64" y="335" width="193" height="61"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Swipe right or left to move to the previous or next screens" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3XM-Ym-byh">
<rect key="frame" x="91" y="400" width="193" height="61"/>
<constraints>
<constraint firstAttribute="width" constant="193" id="4QR-tm-ufp"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="gHo-rF-lxG">
<rect key="frame" x="20" y="22" width="51" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="gHo-rF-lxG">
<rect key="frame" x="20" y="22" width="41" height="33"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
<state key="normal" title="Back">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="titleShadowColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="titleShadowColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<connections>
<action selector="goBack" destination="-1" eventType="touchUpInside" id="jba-wI-8fN"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="vqb-xC-8jj">
<rect key="frame" x="227" y="20" width="73" height="33"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="vqb-xC-8jj">
<rect key="frame" x="287" y="20" width="68" height="33"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
<state key="normal" title="Forward">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="titleShadowColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="titleShadowColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<connections>
<action selector="goForward" destination="-1" eventType="touchUpInside" id="z9b-pk-dQK"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="0.39215686274509803" green="0.78431372549019607" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<color key="backgroundColor" red="0.39215686274509803" green="0.78431372549019607" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="3XM-Ym-byh" firstAttribute="top" secondItem="e9P-CJ-qX9" secondAttribute="bottom" constant="145" id="3j2-Kz-J7a"/>
<constraint firstItem="gHo-rF-lxG" firstAttribute="leading" secondItem="5v3-8q-SxL" secondAttribute="leading" constant="20" id="7gu-G3-StM"/>
<constraint firstItem="3XM-Ym-byh" firstAttribute="centerX" secondItem="5v3-8q-SxL" secondAttribute="centerX" id="9ba-pD-oHS"/>
<constraint firstItem="vqb-xC-8jj" firstAttribute="top" secondItem="5v3-8q-SxL" secondAttribute="top" id="avK-is-m40"/>
<constraint firstAttribute="trailing" secondItem="vqb-xC-8jj" secondAttribute="trailing" constant="20" id="m8s-6W-7K9"/>
<constraint firstItem="e9P-CJ-qX9" firstAttribute="centerY" secondItem="5v3-8q-SxL" secondAttribute="centerY" constant="-103.5" id="pSP-Lg-bRP"/>
<constraint firstItem="e9P-CJ-qX9" firstAttribute="centerX" secondItem="5v3-8q-SxL" secondAttribute="centerX" id="yFf-HW-Efb"/>
<constraint firstItem="gHo-rF-lxG" firstAttribute="top" secondItem="5v3-8q-SxL" secondAttribute="top" constant="2" id="zuj-M7-iUh"/>
</constraints>
<viewLayoutGuide key="safeArea" id="5v3-8q-SxL"/>
</view>
</objects>
</document>
Loading