Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed the pod spec; Added a demo project written in Swift #28

Merged
merged 7 commits into from
Dec 15, 2014
Merged
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
2,143 changes: 2,143 additions & 0 deletions Demo-Swift/Demo-Swift.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?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>IDESourceControlProjectFavoriteDictionaryKey</key>
<false/>
<key>IDESourceControlProjectIdentifier</key>
<string>EA4519DD-5352-4FBB-8870-9AD03120A8EB</string>
<key>IDESourceControlProjectName</key>
<string>Demo-Swift</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>003C14072062B82308B514F809C23037FFFC6F8D</key>
<string>https://github.com/yichizhang/JCTiledScrollView.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>Demo-Swift/Demo-Swift.xcodeproj</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>003C14072062B82308B514F809C23037FFFC6F8D</key>
<string>../../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>https://github.com/yichizhang/JCTiledScrollView.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>111</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>003C14072062B82308B514F809C23037FFFC6F8D</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>003C14072062B82308B514F809C23037FFFC6F8D</string>
<key>IDESourceControlWCCName</key>
<string>JCTiledScrollView</string>
</dict>
</array>
</dict>
</plist>
60 changes: 60 additions & 0 deletions Demo-Swift/Demo-Swift/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
//
// AppDelegate.swift
// Demo-Swift
//
// Created by Yichi on 13/12/2014.
// Copyright (c) 2014 Yichi Zhang. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
var tc = UITabBarController()

var vc1 = ViewController()
vc1.mode = JCDemoType.PDF;
vc1.tabBarItem = UITabBarItem(title: "PDF", image: DemoStyleKit.imageOfPDF, selectedImage: nil)

var vc2 = ViewController()
vc2.mode = JCDemoType.Image
vc2.tabBarItem = UITabBarItem(title: "Image", image: DemoStyleKit.imageOfImage, selectedImage: nil)

tc.viewControllers = [vc1, vc2]
tc.tabBar.translucent = false
window?.rootViewController = tc

return true
}

func applicationWillResignActive(application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

func applicationDidEnterBackground(application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


}

41 changes: 41 additions & 0 deletions Demo-Swift/Demo-Swift/Base.lproj/LaunchScreen.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6214" systemVersion="14A314h" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6207"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB">
<rect key="frame" x="0.0" y="0.0" width="480" height="480"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" Copyright (c) 2014 Yichi Zhang. All rights reserved." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="8ie-xW-0ye">
<rect key="frame" x="20" y="439" width="441" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Demo-Swift" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
<rect key="frame" x="20" y="140" width="441" height="43"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="kId-c2-rCX" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="bottom" multiplier="1/3" constant="1" id="5cJ-9S-tgC"/>
<constraint firstAttribute="centerX" secondItem="kId-c2-rCX" secondAttribute="centerX" id="Koa-jz-hwk"/>
<constraint firstAttribute="bottom" secondItem="8ie-xW-0ye" secondAttribute="bottom" constant="20" id="Kzo-t9-V3l"/>
<constraint firstItem="8ie-xW-0ye" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="MfP-vx-nX0"/>
<constraint firstAttribute="centerX" secondItem="8ie-xW-0ye" secondAttribute="centerX" id="ZEH-qu-HZ9"/>
<constraint firstItem="kId-c2-rCX" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="fvb-Df-36g"/>
</constraints>
<nil key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<point key="canvasLocation" x="548" y="455"/>
</view>
</objects>
</document>
25 changes: 25 additions & 0 deletions Demo-Swift/Demo-Swift/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6254" systemVersion="14B25" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="vXZ-lx-hvc">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="ufC-wZ-h7g">
<objects>
<viewController storyboardIdentifier="ViewController" id="vXZ-lx-hvc" customClass="ViewController" customModule="Demo_Swift" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="jyV-Pf-zRb"/>
<viewControllerLayoutGuide type="bottom" id="2fi-mo-0CV"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="kh9-bI-dsS">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
</document>
14 changes: 14 additions & 0 deletions Demo-Swift/Demo-Swift/Bridging-Header.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// Bridging-Header.h
// Demo-Swift
//
// Created by Yichi on 13/12/2014.
// Copyright (c) 2014 Yichi Zhang. All rights reserved.
//

#ifndef Demo_Swift_Bridging_Header_h
#define Demo_Swift_Bridging_Header_h

#import "JCTiledScrollViewImportAll.h"

#endif
15 changes: 15 additions & 0 deletions Demo-Swift/Demo-Swift/DemoAnnotation.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// DemoAnnotation.swift
// Demo-Swift
//
// Created by Yichi on 13/12/2014.
// Copyright (c) 2014 Yichi Zhang. All rights reserved.
//

import UIKit

class DemoAnnotation: NSObject, JCAnnotation {

var contentPosition = CGPoint()

}
38 changes: 38 additions & 0 deletions Demo-Swift/Demo-Swift/DemoAnnotationView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// DemoAnnotationView.swift
// Demo-Swift
//
// Created by Yichi on 13/12/2014.
// Copyright (c) 2014 Yichi Zhang. All rights reserved.
//

import UIKit

class DemoAnnotationView: JCAnnotationView {

var imageView:UIImageView!

override init!(frame: CGRect, annotation: JCAnnotation!, reuseIdentifier: String!) {

super.init(frame: frame, annotation: annotation, reuseIdentifier: reuseIdentifier)
imageView = UIImageView()
addSubview(imageView)

}

required init(coder aDecoder: NSCoder) {

super.init(coder: aDecoder);
}

override func sizeThatFits(size: CGSize) -> CGSize {
return CGSizeMake(max(imageView.image!.size.width,30), max(imageView.image!.size.height,30));
}

override func layoutSubviews() {

imageView.sizeToFit();
imageView.frame = imageView.bounds
}

}
139 changes: 139 additions & 0 deletions Demo-Swift/Demo-Swift/DemoStyleKit.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
//
// DemoStyleKit.swift
// JCTiledScrollViewDemo-Swift
//
// Created by Yichi Zhang on 13/12/2014.
// Copyright (c) 2014 Yichi Zhang. All rights reserved.
//
// Generated by PaintCode (www.paintcodeapp.com)
//



import UIKit

public class DemoStyleKit : NSObject {

//// Cache

private struct Cache {
static var imageOfPDF: UIImage?
static var pDFTargets: [AnyObject]?
static var imageOfImage: UIImage?
static var imageTargets: [AnyObject]?
}

//// Drawing Methods

public class func drawPDF() {
//// General Declarations
let context = UIGraphicsGetCurrentContext()

//// Text Drawing
let textRect = CGRectMake(0, 0, 25, 25)
var textTextContent = NSString(string: "PDF")
let textStyle = NSMutableParagraphStyle.defaultParagraphStyle().mutableCopy() as NSMutableParagraphStyle
textStyle.alignment = NSTextAlignment.Center

let textFontAttributes = [NSFontAttributeName: UIFont(name: "HelveticaNeue-CondensedBlack", size: UIFont.systemFontSize())!, NSForegroundColorAttributeName: UIColor.blackColor(), NSParagraphStyleAttributeName: textStyle]

let textTextHeight: CGFloat = textTextContent.boundingRectWithSize(CGSizeMake(textRect.width, CGFloat.infinity), options: NSStringDrawingOptions.UsesLineFragmentOrigin, attributes: textFontAttributes, context: nil).size.height
CGContextSaveGState(context)
CGContextClipToRect(context, textRect);
textTextContent.drawInRect(CGRectMake(textRect.minX, textRect.minY + (textRect.height - textTextHeight) / 2, textRect.width, textTextHeight), withAttributes: textFontAttributes)
CGContextRestoreGState(context)
}

public class func drawImage() {

//// Bezier 2 Drawing
var bezier2Path = UIBezierPath()
bezier2Path.moveToPoint(CGPointMake(9, 6))
bezier2Path.addCurveToPoint(CGPointMake(8.54, 6.05), controlPoint1: CGPointMake(8.84, 6), controlPoint2: CGPointMake(8.68, 6.02))
bezier2Path.addCurveToPoint(CGPointMake(7, 8), controlPoint1: CGPointMake(7.65, 6.26), controlPoint2: CGPointMake(7, 7.06))
bezier2Path.addCurveToPoint(CGPointMake(9, 10), controlPoint1: CGPointMake(7, 9.1), controlPoint2: CGPointMake(7.9, 10))
bezier2Path.addCurveToPoint(CGPointMake(11, 8), controlPoint1: CGPointMake(10.1, 10), controlPoint2: CGPointMake(11, 9.1))
bezier2Path.addCurveToPoint(CGPointMake(9, 6), controlPoint1: CGPointMake(11, 6.9), controlPoint2: CGPointMake(10.1, 6))
bezier2Path.closePath()
bezier2Path.moveToPoint(CGPointMake(15.57, 11))
bezier2Path.addCurveToPoint(CGPointMake(13.86, 14.59), controlPoint1: CGPointMake(15.57, 11), controlPoint2: CGPointMake(14.61, 13.02))
bezier2Path.addCurveToPoint(CGPointMake(13, 16.4), controlPoint1: CGPointMake(13.39, 15.59), controlPoint2: CGPointMake(13, 16.4))
bezier2Path.addCurveToPoint(CGPointMake(12.07, 15.43), controlPoint1: CGPointMake(13, 16.4), controlPoint2: CGPointMake(12.58, 15.95))
bezier2Path.addCurveToPoint(CGPointMake(11.83, 15.18), controlPoint1: CGPointMake(11.99, 15.34), controlPoint2: CGPointMake(11.91, 15.26))
bezier2Path.addCurveToPoint(CGPointMake(10.43, 13.7), controlPoint1: CGPointMake(11.15, 14.46), controlPoint2: CGPointMake(10.43, 13.7))
bezier2Path.addLineToPoint(CGPointMake(7, 20))
bezier2Path.addLineToPoint(CGPointMake(19, 20))
bezier2Path.addLineToPoint(CGPointMake(15.57, 11))
bezier2Path.closePath()
bezier2Path.moveToPoint(CGPointMake(22, 3))
bezier2Path.addCurveToPoint(CGPointMake(22, 22), controlPoint1: CGPointMake(22, 3), controlPoint2: CGPointMake(22, 22))
bezier2Path.addLineToPoint(CGPointMake(3, 22))
bezier2Path.addLineToPoint(CGPointMake(3, 3))
bezier2Path.addLineToPoint(CGPointMake(22, 3))
bezier2Path.addLineToPoint(CGPointMake(22, 3))
bezier2Path.closePath()
UIColor.blackColor().setFill()
bezier2Path.fill()
}

//// Generated Images

public class var imageOfPDF: UIImage {
if Cache.imageOfPDF != nil {
return Cache.imageOfPDF!
}

UIGraphicsBeginImageContextWithOptions(CGSizeMake(25, 25), false, 0)
DemoStyleKit.drawPDF()

Cache.imageOfPDF = UIGraphicsGetImageFromCurrentImageContext()!
UIGraphicsEndImageContext()

return Cache.imageOfPDF!
}

public class var imageOfImage: UIImage {
if Cache.imageOfImage != nil {
return Cache.imageOfImage!
}

UIGraphicsBeginImageContextWithOptions(CGSizeMake(25, 25), false, 0)
DemoStyleKit.drawImage()

Cache.imageOfImage = UIGraphicsGetImageFromCurrentImageContext()!
UIGraphicsEndImageContext()

return Cache.imageOfImage!
}

//// Customization Infrastructure

@IBOutlet var pDFTargets: [AnyObject]! {
get { return Cache.pDFTargets }
set {
Cache.pDFTargets = newValue
for target: AnyObject in newValue {
target.setImage(DemoStyleKit.imageOfPDF)
}
}
}

@IBOutlet var imageTargets: [AnyObject]! {
get { return Cache.imageTargets }
set {
Cache.imageTargets = newValue
for target: AnyObject in newValue {
target.setImage(DemoStyleKit.imageOfImage)
}
}
}

}

@objc protocol StyleKitSettableImage {
func setImage(image: UIImage!)
}

@objc protocol StyleKitSettableSelectedImage {
func setSelectedImage(image: UIImage!)
}
Loading