Skip to content

Commit

Permalink
Change directory structure
Browse files Browse the repository at this point in the history
  • Loading branch information
wangmchn committed Apr 20, 2016
1 parent 5dc75d9 commit 5cd0ec2
Show file tree
Hide file tree
Showing 40 changed files with 2,906 additions and 625 deletions.
551 changes: 0 additions & 551 deletions Example/Use Code/Example.xcodeproj/project.pbxproj

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
objects = {

/* Begin PBXBuildFile section */
4D45BF591CC7A25A003F0151 /* FooldView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D45BF541CC7A25A003F0151 /* FooldView.swift */; };
4D45BF5A1CC7A25A003F0151 /* MenuItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D45BF551CC7A25A003F0151 /* MenuItem.swift */; };
4D45BF5B1CC7A25A003F0151 /* MenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D45BF561CC7A25A003F0151 /* MenuView.swift */; };
4D45BF5C1CC7A25A003F0151 /* PageController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D45BF571CC7A25A003F0151 /* PageController.swift */; };
4D45BF5D1CC7A25A003F0151 /* ProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D45BF581CC7A25A003F0151 /* ProgressView.swift */; };
4DF0A9781C39847100731373 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4DF0A9771C39847100731373 /* AppDelegate.swift */; };
4DF0A97A1C39847100731373 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4DF0A9791C39847100731373 /* ViewController.swift */; };
4DF0A97D1C39847100731373 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4DF0A97B1C39847100731373 /* Main.storyboard */; };
4DF0A97F1C39847100731373 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4DF0A97E1C39847100731373 /* Assets.xcassets */; };
4DF0A9821C39847100731373 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4DF0A9801C39847100731373 /* LaunchScreen.storyboard */; };
4DF0A98D1C39847100731373 /* StoryboardExampleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4DF0A98C1C39847100731373 /* StoryboardExampleTests.swift */; };
4DF0A9981C39847100731373 /* StoryboardExampleUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4DF0A9971C39847100731373 /* StoryboardExampleUITests.swift */; };
4DF0A9AB1C39848100731373 /* FooldView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4DF0A9A61C39848100731373 /* FooldView.swift */; };
4DF0A9AC1C39848100731373 /* MenuItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4DF0A9A71C39848100731373 /* MenuItem.swift */; };
4DF0A9AD1C39848100731373 /* MenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4DF0A9A81C39848100731373 /* MenuView.swift */; };
4DF0A9AE1C39848100731373 /* PageController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4DF0A9A91C39848100731373 /* PageController.swift */; };
4DF0A9AF1C39848100731373 /* ProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4DF0A9AA1C39848100731373 /* ProgressView.swift */; };
4DF0A9B21C3984EB00731373 /* CustomPageController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4DF0A9B11C3984EB00731373 /* CustomPageController.swift */; };
4DF0A9B51C3986D600731373 /* TableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4DF0A9B41C3986D600731373 /* TableViewController.swift */; };
/* End PBXBuildFile section */
Expand All @@ -41,6 +41,11 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
4D45BF541CC7A25A003F0151 /* FooldView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FooldView.swift; sourceTree = "<group>"; };
4D45BF551CC7A25A003F0151 /* MenuItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MenuItem.swift; sourceTree = "<group>"; };
4D45BF561CC7A25A003F0151 /* MenuView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MenuView.swift; sourceTree = "<group>"; };
4D45BF571CC7A25A003F0151 /* PageController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PageController.swift; sourceTree = "<group>"; };
4D45BF581CC7A25A003F0151 /* ProgressView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProgressView.swift; sourceTree = "<group>"; };
4DF0A9741C39847100731373 /* StoryboardExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = StoryboardExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
4DF0A9771C39847100731373 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
4DF0A9791C39847100731373 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
Expand All @@ -54,11 +59,6 @@
4DF0A9931C39847100731373 /* StoryboardExampleUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = StoryboardExampleUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
4DF0A9971C39847100731373 /* StoryboardExampleUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoryboardExampleUITests.swift; sourceTree = "<group>"; };
4DF0A9991C39847100731373 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
4DF0A9A61C39848100731373 /* FooldView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FooldView.swift; sourceTree = "<group>"; };
4DF0A9A71C39848100731373 /* MenuItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MenuItem.swift; sourceTree = "<group>"; };
4DF0A9A81C39848100731373 /* MenuView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MenuView.swift; sourceTree = "<group>"; };
4DF0A9A91C39848100731373 /* PageController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PageController.swift; sourceTree = "<group>"; };
4DF0A9AA1C39848100731373 /* ProgressView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProgressView.swift; sourceTree = "<group>"; };
4DF0A9B11C3984EB00731373 /* CustomPageController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CustomPageController.swift; path = ParentController/CustomPageController.swift; sourceTree = "<group>"; };
4DF0A9B41C3986D600731373 /* TableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -88,6 +88,18 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
4D45BF531CC7A25A003F0151 /* PageController */ = {
isa = PBXGroup;
children = (
4D45BF541CC7A25A003F0151 /* FooldView.swift */,
4D45BF551CC7A25A003F0151 /* MenuItem.swift */,
4D45BF561CC7A25A003F0151 /* MenuView.swift */,
4D45BF571CC7A25A003F0151 /* PageController.swift */,
4D45BF581CC7A25A003F0151 /* ProgressView.swift */,
);
path = PageController;
sourceTree = "<group>";
};
4DF0A96B1C39847100731373 = {
isa = PBXGroup;
children = (
Expand All @@ -111,9 +123,9 @@
4DF0A9761C39847100731373 /* StoryboardExample */ = {
isa = PBXGroup;
children = (
4D45BF531CC7A25A003F0151 /* PageController */,
4DF0A9B31C3986B800731373 /* ChildControllers */,
4DF0A9B01C3984BA00731373 /* ParentController */,
4DF0A9A51C39848100731373 /* PageController */,
4DF0A9771C39847100731373 /* AppDelegate.swift */,
4DF0A97B1C39847100731373 /* Main.storyboard */,
4DF0A97E1C39847100731373 /* Assets.xcassets */,
Expand Down Expand Up @@ -141,19 +153,6 @@
path = StoryboardExampleUITests;
sourceTree = "<group>";
};
4DF0A9A51C39848100731373 /* PageController */ = {
isa = PBXGroup;
children = (
4DF0A9A61C39848100731373 /* FooldView.swift */,
4DF0A9A71C39848100731373 /* MenuItem.swift */,
4DF0A9A81C39848100731373 /* MenuView.swift */,
4DF0A9A91C39848100731373 /* PageController.swift */,
4DF0A9AA1C39848100731373 /* ProgressView.swift */,
);
name = PageController;
path = ../../../../PageController;
sourceTree = "<group>";
};
4DF0A9B01C3984BA00731373 /* ParentController */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -302,15 +301,15 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4DF0A9AD1C39848100731373 /* MenuView.swift in Sources */,
4D45BF5C1CC7A25A003F0151 /* PageController.swift in Sources */,
4D45BF5B1CC7A25A003F0151 /* MenuView.swift in Sources */,
4DF0A9B21C3984EB00731373 /* CustomPageController.swift in Sources */,
4DF0A97A1C39847100731373 /* ViewController.swift in Sources */,
4DF0A9AE1C39848100731373 /* PageController.swift in Sources */,
4DF0A9AC1C39848100731373 /* MenuItem.swift in Sources */,
4DF0A9AF1C39848100731373 /* ProgressView.swift in Sources */,
4DF0A9AB1C39848100731373 /* FooldView.swift in Sources */,
4DF0A9B51C3986D600731373 /* TableViewController.swift in Sources */,
4D45BF5A1CC7A25A003F0151 /* MenuItem.swift in Sources */,
4D45BF591CC7A25A003F0151 /* FooldView.swift in Sources */,
4DF0A9781C39847100731373 /* AppDelegate.swift in Sources */,
4D45BF5D1CC7A25A003F0151 /* ProgressView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -535,6 +534,7 @@
4DF0A99E1C39847100731373 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
4DF0A99F1C39847100731373 /* Build configuration list for PBXNativeTarget "StoryboardExampleTests" */ = {
isa = XCConfigurationList;
Expand All @@ -543,6 +543,7 @@
4DF0A9A11C39847100731373 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
4DF0A9A21C39847100731373 /* Build configuration list for PBXNativeTarget "StoryboardExampleUITests" */ = {
isa = XCConfigurationList;
Expand All @@ -551,6 +552,7 @@
4DF0A9A41C39847100731373 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="riQ-5R-hbg">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="riQ-5R-hbg">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
</dependencies>
<scenes>
<!--Storyboard Test-->
Expand Down
File renamed without changes.
55 changes: 55 additions & 0 deletions StoryboardExample/StoryboardExample/PageController/FooldView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//
// FooldView.swift
// PageController
//
// Created by Mark on 15/10/20.
// Copyright © 2015年 Wecan Studio. All rights reserved.
//

import UIKit

class FooldView: ProgressView {

// MARK: - Vars
var hollow = false
private var margin: CGFloat = 0.0
private var radius: CGFloat = 0.0
private var height: CGFloat = 0.0

// MARK: - Private funcs
override func willMoveToSuperview(newSuperview: UIView?) {
height = frame.size.height
margin = height * 0.15
radius = (height - margin * 2.0) / 2.0
}

override func drawRect(rect: CGRect) {
// Drawing code
let currentIndex = Int(progress)
let rate = progress - CGFloat(currentIndex)
let nextIndex = (currentIndex + 1) >= itemFrames.count ? currentIndex : currentIndex + 1
let currentFrame = itemFrames[currentIndex]
let currentWidth = currentFrame.size.width
let currentX = currentFrame.origin.x
let nextWidth = itemFrames[nextIndex].size.width
let nextX = self.itemFrames[nextIndex].origin.x
let startX = currentX + (nextX - currentX) * rate
let endX = startX + currentWidth + (nextWidth - currentWidth) * rate
let ctx = UIGraphicsGetCurrentContext()
CGContextTranslateCTM(ctx, 0.0, height)
CGContextScaleCTM(ctx, 1.0, -1.0)
CGContextAddArc(ctx, startX + radius, height / 2.0, radius, CGFloat(M_PI_2), CGFloat(M_PI_2) * 3, 0)
CGContextAddLineToPoint(ctx, endX - radius, margin)
CGContextAddArc(ctx, endX - radius, height / 2.0, radius, CGFloat(-M_PI_2), CGFloat(M_PI_2), 0)
CGContextClosePath(ctx)
if hollow == true {
CGContextSetStrokeColorWithColor(ctx, color)
CGContextStrokePath(ctx)
return
}
CGContextClosePath(ctx)
CGContextSetFillColorWithColor(ctx, color)
CGContextFillPath(ctx)
}

}
88 changes: 88 additions & 0 deletions StoryboardExample/StoryboardExample/PageController/MenuItem.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
//
// MenuItem.swift
// PageController
//
// Created by Mark on 15/10/20.
// Copyright © 2015年 Wecan Studio. All rights reserved.
//

import UIKit

protocol MenuItemDelegate: NSObjectProtocol {
func didSelectedMenuItem(menuItem: MenuItem)
}

class MenuItem: UILabel {

// MARK: - Public vars
var normalSize: CGFloat = 15.0
var selectedSize: CGFloat = 18.0
weak var delegate: MenuItemDelegate?

var selected = false {
didSet { rate = (selected == false) ? 0.0 : 1.0 }
}

var rate: CGFloat = 0.0 {
didSet {
let red = normalComponents.red + (selectedComponets.red - normalComponents.red) * rate
let green = normalComponents.green + (selectedComponets.green - normalComponents.green) * rate
let blue = normalComponents.blue + (selectedComponets.blue - normalComponents.blue) * rate
let alpha = normalComponents.alpha + (selectedComponets.alpha - normalComponents.alpha) * rate
let minScale = normalSize / selectedSize
let trueScale = minScale + (1 - minScale) * rate
textColor = UIColor(red: red, green: green, blue: blue, alpha: alpha)
transform = CGAffineTransformMakeScale(trueScale, trueScale)
}
}

var normalColor: UIColor? {
didSet {
normalColor?.getRed(&normalComponents.red, green: &normalComponents.green, blue: &normalComponents.blue, alpha: &normalComponents.alpha)
}
}

var selectedColor: UIColor? {
didSet {
selectedColor?.getRed(&selectedComponets.red, green: &selectedComponets.green, blue: &selectedComponets.blue, alpha: &selectedComponets.alpha)
}
}

// MARK: - Private vars
private var normalComponents: (red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) = (0.0, 0.0, 0.0, 0.0)
private var selectedComponets: (red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) = (0.0, 0.0, 0.0, 0.0)

// MARK: - Public funcs
func selectWithAnimation(select: Bool) -> Void {
if selected == select { return }
UIView.animateWithDuration(0.3) { () -> Void in
if self.selected == true {
self.rate = 0.0
} else {
self.rate = 1.0
}
self.selected = select
}
}

override init(frame: CGRect) {
super.init(frame: frame)
setup()
}

required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setup()
}

// MARK: - Private funcs
private func setup() {
textAlignment = NSTextAlignment.Center
userInteractionEnabled = true
backgroundColor = UIColor.clearColor()
}

override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
delegate?.didSelectedMenuItem(self)
}
}
Loading

0 comments on commit 5cd0ec2

Please sign in to comment.