Initial Commit

This commit is contained in:
Yannick Loriot 2015-09-06 22:21:51 +02:00
commit 917bd3e0f6
12 changed files with 986 additions and 0 deletions

18
.gitignore vendored Normal file
View File

@ -0,0 +1,18 @@
# Xcode
.DS_Store
*/build/*
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
profile
*.moved-aside
DerivedData
.idea/
*.hmap
*.xccheckout

View File

@ -0,0 +1,194 @@
//
// DynamicButton.swift
// DynamicButtonExample
//
// Created by Yannick LORIOT on 29/08/15.
// Copyright (c) 2015 Yannick LORIOT. All rights reserved.
//
import UIKit
@IBDesignable final public class DynamicButton: UIButton {
public enum Style: String {
case Hamburger = "Hamburger"
case Close = "Close"
}
private let line1Layer = CAShapeLayer()
private let line2Layer = CAShapeLayer()
private let line3Layer = CAShapeLayer()
private let circleLayer = CAShapeLayer()
private lazy var allLayers: [CAShapeLayer] = {
return [self.line1Layer, self.line2Layer, self.line3Layer, self.circleLayer]
}()
override public init(frame: CGRect) {
super.init(frame: frame)
setup()
}
required public init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setup()
}
// MARK: - Managing the Button Setup
private var intrinsicSquareSize: CGFloat = 0
private var offset = CGPointZero
private var centerPoint = CGPointZero
private func setup() {
addTarget(self, action: "highlightAction", forControlEvents: .TouchDown)
addTarget(self, action: "highlightAction", forControlEvents: .TouchDragEnter)
addTarget(self, action: "unhighlightAction", forControlEvents: .TouchDragExit)
addTarget(self, action: "unhighlightAction", forControlEvents: .TouchUpInside)
addTarget(self, action: "unhighlightAction", forControlEvents: .TouchUpOutside)
addTarget(self, action: "unhighlightAction", forControlEvents: .TouchCancel)
for sublayer in allLayers {
sublayer.fillColor = UIColor.clearColor().CGColor
sublayer.anchorPoint = CGPointMake(0, 0)
sublayer.lineJoin = kCALineJoinRound
sublayer.lineCap = kCALineCapRound
sublayer.contentsScale = layer.contentsScale
sublayer.path = UIBezierPath().CGPath
sublayer.lineWidth = 2
sublayer.strokeColor = UIColor.blackColor().CGColor
layer.addSublayer(sublayer)
}
// in case the button is not square, the offset will be use to keep our CGPath's centered in it.
let width = CGRectGetWidth(bounds) - contentEdgeInsets.left + contentEdgeInsets.right
let height = CGRectGetHeight(bounds) - contentEdgeInsets.top + contentEdgeInsets.bottom
intrinsicSquareSize = min(width, height)
offset = CGPointMake((CGRectGetWidth(bounds) - intrinsicSquareSize) / 2, (CGRectGetHeight(bounds) - intrinsicSquareSize) / 2)
centerPoint = CGPointMake(CGRectGetMidX(bounds), CGRectGetMidY(bounds))
buttonStyle = .Hamburger
}
private var _style: Style = .Hamburger
@IBInspectable var buttonStyle: Style {
get {
return _style
}
set (newValue) {
setStyle(newValue, animated: false)
}
}
func setStyle(style: Style, animated: Bool) {
_style = style
let newCirclePath: CGPathRef
let newLine1Path: CGPathRef
let newLine2Path: CGPathRef
let newLine3Path: CGPathRef
let newCircleAlpha: Float
let newLine1Alpha: Float
switch style {
case .Hamburger:
newCirclePath = createCenteredCircleWithRadius(intrinsicSquareSize / 20)
newCircleAlpha = 0
newLine1Path = createCenteredLineWithRadius(intrinsicSquareSize / 2, angle: 0, offset: CGPointZero)
newLine1Alpha = 1
newLine2Path = createCenteredLineWithRadius(intrinsicSquareSize / 2, angle: 0, offset: CGPointMake(0, intrinsicSquareSize / -2 / 1.6))
newLine3Path = createCenteredLineWithRadius(intrinsicSquareSize / 2, angle: 0, offset: CGPointMake(0, intrinsicSquareSize / 2 / 1.6))
case .Close:
newCirclePath = createCenteredCircleWithRadius(intrinsicSquareSize / 20)
newCircleAlpha = 0
newLine1Path = createCenteredLineWithRadius(intrinsicSquareSize / 2, angle: 0, offset: CGPointZero)
newLine1Alpha = 0
newLine2Path = createCenteredLineWithRadius(intrinsicSquareSize / 2, angle: CGFloat(M_PI_4), offset: CGPointZero)
newLine3Path = createCenteredLineWithRadius(intrinsicSquareSize / 2, angle: CGFloat(-M_PI_4), offset: CGPointZero)
}
if animated {
let configurations: [(keyPath: String, layer: CALayer, oldValue: AnyObject?, newValue: AnyObject?, key: String)] = [
(keyPath: "path", layer: circleLayer, oldValue: circleLayer.path, newValue: newCirclePath, key: "animateCirclePath"),
(keyPath: "opacity", layer: circleLayer, oldValue: circleLayer.opacity, newValue: newCircleAlpha, key: "animateCircleOpacityPath"),
(keyPath: "path", layer: line1Layer, oldValue: line1Layer.path, newValue: newLine1Path, key: "animateLine1Path"),
(keyPath: "opacity", layer: line1Layer, oldValue: line1Layer.opacity, newValue: newLine1Alpha, key: "animateLine1OpacityPath"),
(keyPath: "path", layer: line2Layer, oldValue: line2Layer.path, newValue: newLine2Path, key: "animateLine2Path"),
(keyPath: "path", layer: line3Layer, oldValue: line3Layer.path, newValue: newLine3Path, key: "animateLine3Path")
]
for config in configurations {
let anim = CABasicAnimation(keyPath: config.keyPath)
anim.removedOnCompletion = false
anim.duration = 0.2
anim.fromValue = config.oldValue
anim.toValue = config.newValue
anim.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionDefault)
config.layer.addAnimation(anim, forKey: "animateCirclePath")
}
}
circleLayer.path = newCirclePath;
circleLayer.opacity = newCircleAlpha
line1Layer.path = newLine1Path
line1Layer.opacity = newLine1Alpha
line2Layer.path = newLine2Path
line3Layer.path = newLine3Path
}
internal func createCenteredCircleWithRadius(radius: CGFloat) -> CGPathRef {
let path = CGPathCreateMutable()
CGPathMoveToPoint(path, nil, centerPoint.x + radius, centerPoint.y)
CGPathAddArc(path, nil, centerPoint.x, centerPoint.y, radius, 0, 2 * CGFloat(M_PI), false)
return path
}
// you are responsible for releasing the return CGPath
internal func createCenteredLineWithRadius(radius: CGFloat, angle: CGFloat, offset: CGPoint) -> CGPathRef {
let path = CGPathCreateMutable()
let c = cos(angle)
let s = sin(angle)
CGPathMoveToPoint(path, nil, centerPoint.x + offset.x + radius * c, centerPoint.y + offset.y + radius * s)
CGPathAddLineToPoint(path, nil, centerPoint.x + offset.x - radius * c, centerPoint.y + offset.y - radius * s)
return path
}
// MARK: - Action Methods
internal func highlightAction() {
for sublayer in allLayers {
sublayer.strokeColor = UIColor.redColor().CGColor
}
let anim = CABasicAnimation(keyPath: "transform.scale")
anim.duration = 0.2
anim.removedOnCompletion = false
anim.toValue = 1.2
anim.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionDefault)
layer.addAnimation(anim, forKey: "scaleup")
}
internal func unhighlightAction() {
for sublayer in allLayers {
sublayer.strokeColor = UIColor.blackColor().CGColor
}
let anim = CABasicAnimation(keyPath: "transform.scale")
anim.duration = 0.2
anim.removedOnCompletion = false
anim.toValue = 1
anim.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionDefault)
layer.addAnimation(anim, forKey: "scaleup")
}
}

View File

@ -0,0 +1,441 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
CE77470D1B9CD4E5001FF79E /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE77470C1B9CD4E5001FF79E /* AppDelegate.swift */; };
CE77470F1B9CD4E5001FF79E /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE77470E1B9CD4E5001FF79E /* ViewController.swift */; };
CE7747121B9CD4E5001FF79E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CE7747101B9CD4E5001FF79E /* Main.storyboard */; };
CE7747141B9CD4E5001FF79E /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CE7747131B9CD4E5001FF79E /* Images.xcassets */; };
CE7747171B9CD4E5001FF79E /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = CE7747151B9CD4E5001FF79E /* LaunchScreen.xib */; };
CE7747231B9CD4E5001FF79E /* DynamicButtonExampleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE7747221B9CD4E5001FF79E /* DynamicButtonExampleTests.swift */; };
CE77472E1B9CD4F6001FF79E /* DynamicButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE77472D1B9CD4F6001FF79E /* DynamicButton.swift */; };
CE77472F1B9CD4F6001FF79E /* DynamicButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE77472D1B9CD4F6001FF79E /* DynamicButton.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
CE77471D1B9CD4E5001FF79E /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = CE7746FF1B9CD4E5001FF79E /* Project object */;
proxyType = 1;
remoteGlobalIDString = CE7747061B9CD4E5001FF79E;
remoteInfo = DynamicButtonExample;
};
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
CE7747071B9CD4E5001FF79E /* DynamicButtonExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DynamicButtonExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
CE77470B1B9CD4E5001FF79E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
CE77470C1B9CD4E5001FF79E /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
CE77470E1B9CD4E5001FF79E /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
CE7747111B9CD4E5001FF79E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
CE7747131B9CD4E5001FF79E /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
CE7747161B9CD4E5001FF79E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = "<group>"; };
CE77471C1B9CD4E5001FF79E /* DynamicButtonExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DynamicButtonExampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
CE7747211B9CD4E5001FF79E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
CE7747221B9CD4E5001FF79E /* DynamicButtonExampleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DynamicButtonExampleTests.swift; sourceTree = "<group>"; };
CE77472D1B9CD4F6001FF79E /* DynamicButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DynamicButton.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
CE7747041B9CD4E5001FF79E /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
CE7747191B9CD4E5001FF79E /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
CE7746FE1B9CD4E5001FF79E = {
isa = PBXGroup;
children = (
CE77472C1B9CD4F6001FF79E /* DynamicButton */,
CE7747091B9CD4E5001FF79E /* DynamicButtonExample */,
CE77471F1B9CD4E5001FF79E /* DynamicButtonExampleTests */,
CE7747081B9CD4E5001FF79E /* Products */,
);
sourceTree = "<group>";
};
CE7747081B9CD4E5001FF79E /* Products */ = {
isa = PBXGroup;
children = (
CE7747071B9CD4E5001FF79E /* DynamicButtonExample.app */,
CE77471C1B9CD4E5001FF79E /* DynamicButtonExampleTests.xctest */,
);
name = Products;
sourceTree = "<group>";
};
CE7747091B9CD4E5001FF79E /* DynamicButtonExample */ = {
isa = PBXGroup;
children = (
CE77470C1B9CD4E5001FF79E /* AppDelegate.swift */,
CE77470E1B9CD4E5001FF79E /* ViewController.swift */,
CE7747101B9CD4E5001FF79E /* Main.storyboard */,
CE7747131B9CD4E5001FF79E /* Images.xcassets */,
CE7747151B9CD4E5001FF79E /* LaunchScreen.xib */,
CE77470A1B9CD4E5001FF79E /* Supporting Files */,
);
path = DynamicButtonExample;
sourceTree = "<group>";
};
CE77470A1B9CD4E5001FF79E /* Supporting Files */ = {
isa = PBXGroup;
children = (
CE77470B1B9CD4E5001FF79E /* Info.plist */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
CE77471F1B9CD4E5001FF79E /* DynamicButtonExampleTests */ = {
isa = PBXGroup;
children = (
CE7747221B9CD4E5001FF79E /* DynamicButtonExampleTests.swift */,
CE7747201B9CD4E5001FF79E /* Supporting Files */,
);
path = DynamicButtonExampleTests;
sourceTree = "<group>";
};
CE7747201B9CD4E5001FF79E /* Supporting Files */ = {
isa = PBXGroup;
children = (
CE7747211B9CD4E5001FF79E /* Info.plist */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
CE77472C1B9CD4F6001FF79E /* DynamicButton */ = {
isa = PBXGroup;
children = (
CE77472D1B9CD4F6001FF79E /* DynamicButton.swift */,
);
name = DynamicButton;
path = ../../DynamicButton;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
CE7747061B9CD4E5001FF79E /* DynamicButtonExample */ = {
isa = PBXNativeTarget;
buildConfigurationList = CE7747261B9CD4E5001FF79E /* Build configuration list for PBXNativeTarget "DynamicButtonExample" */;
buildPhases = (
CE7747031B9CD4E5001FF79E /* Sources */,
CE7747041B9CD4E5001FF79E /* Frameworks */,
CE7747051B9CD4E5001FF79E /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = DynamicButtonExample;
productName = DynamicButtonExample;
productReference = CE7747071B9CD4E5001FF79E /* DynamicButtonExample.app */;
productType = "com.apple.product-type.application";
};
CE77471B1B9CD4E5001FF79E /* DynamicButtonExampleTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = CE7747291B9CD4E5001FF79E /* Build configuration list for PBXNativeTarget "DynamicButtonExampleTests" */;
buildPhases = (
CE7747181B9CD4E5001FF79E /* Sources */,
CE7747191B9CD4E5001FF79E /* Frameworks */,
CE77471A1B9CD4E5001FF79E /* Resources */,
);
buildRules = (
);
dependencies = (
CE77471E1B9CD4E5001FF79E /* PBXTargetDependency */,
);
name = DynamicButtonExampleTests;
productName = DynamicButtonExampleTests;
productReference = CE77471C1B9CD4E5001FF79E /* DynamicButtonExampleTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
CE7746FF1B9CD4E5001FF79E /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0640;
ORGANIZATIONNAME = "Yannick LORIOT";
TargetAttributes = {
CE7747061B9CD4E5001FF79E = {
CreatedOnToolsVersion = 6.4;
};
CE77471B1B9CD4E5001FF79E = {
CreatedOnToolsVersion = 6.4;
TestTargetID = CE7747061B9CD4E5001FF79E;
};
};
};
buildConfigurationList = CE7747021B9CD4E5001FF79E /* Build configuration list for PBXProject "DynamicButtonExample" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = CE7746FE1B9CD4E5001FF79E;
productRefGroup = CE7747081B9CD4E5001FF79E /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
CE7747061B9CD4E5001FF79E /* DynamicButtonExample */,
CE77471B1B9CD4E5001FF79E /* DynamicButtonExampleTests */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
CE7747051B9CD4E5001FF79E /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
CE7747121B9CD4E5001FF79E /* Main.storyboard in Resources */,
CE7747171B9CD4E5001FF79E /* LaunchScreen.xib in Resources */,
CE7747141B9CD4E5001FF79E /* Images.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
CE77471A1B9CD4E5001FF79E /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
CE7747031B9CD4E5001FF79E /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
CE77470F1B9CD4E5001FF79E /* ViewController.swift in Sources */,
CE77470D1B9CD4E5001FF79E /* AppDelegate.swift in Sources */,
CE77472E1B9CD4F6001FF79E /* DynamicButton.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
CE7747181B9CD4E5001FF79E /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
CE7747231B9CD4E5001FF79E /* DynamicButtonExampleTests.swift in Sources */,
CE77472F1B9CD4F6001FF79E /* DynamicButton.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
CE77471E1B9CD4E5001FF79E /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = CE7747061B9CD4E5001FF79E /* DynamicButtonExample */;
targetProxy = CE77471D1B9CD4E5001FF79E /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
CE7747101B9CD4E5001FF79E /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
CE7747111B9CD4E5001FF79E /* Base */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
CE7747151B9CD4E5001FF79E /* LaunchScreen.xib */ = {
isa = PBXVariantGroup;
children = (
CE7747161B9CD4E5001FF79E /* Base */,
);
name = LaunchScreen.xib;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
CE7747241B9CD4E5001FF79E /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.4;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
CE7747251B9CD4E5001FF79E /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.4;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
CE7747271B9CD4E5001FF79E /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = DynamicButtonExample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
CE7747281B9CD4E5001FF79E /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = DynamicButtonExample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
CE77472A1B9CD4E5001FF79E /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
INFOPLIST_FILE = DynamicButtonExampleTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DynamicButtonExample.app/DynamicButtonExample";
};
name = Debug;
};
CE77472B1B9CD4E5001FF79E /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
INFOPLIST_FILE = DynamicButtonExampleTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DynamicButtonExample.app/DynamicButtonExample";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
CE7747021B9CD4E5001FF79E /* Build configuration list for PBXProject "DynamicButtonExample" */ = {
isa = XCConfigurationList;
buildConfigurations = (
CE7747241B9CD4E5001FF79E /* Debug */,
CE7747251B9CD4E5001FF79E /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
CE7747261B9CD4E5001FF79E /* Build configuration list for PBXNativeTarget "DynamicButtonExample" */ = {
isa = XCConfigurationList;
buildConfigurations = (
CE7747271B9CD4E5001FF79E /* Debug */,
CE7747281B9CD4E5001FF79E /* Release */,
);
defaultConfigurationIsVisible = 0;
};
CE7747291B9CD4E5001FF79E /* Build configuration list for PBXNativeTarget "DynamicButtonExampleTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
CE77472A1B9CD4E5001FF79E /* Debug */,
CE77472B1B9CD4E5001FF79E /* Release */,
);
defaultConfigurationIsVisible = 0;
};
/* End XCConfigurationList section */
};
rootObject = CE7746FF1B9CD4E5001FF79E /* Project object */;
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:DynamicButtonExample.xcodeproj">
</FileRef>
</Workspace>

View File

@ -0,0 +1,46 @@
//
// AppDelegate.swift
// DynamicButtonExample
//
// Created by Yannick LORIOT on 06/09/15.
// Copyright (c) 2015 Yannick LORIOT. 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.
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:.
}
}

View File

@ -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) 2015 Yannick LORIOT. 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="DynamicButtonExample" 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>

View File

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7706" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="DynamicButtonExample" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="NK4-aT-Mei" customClass="DynamicButton" customModule="DynamicButtonExample" customModuleProvider="target">
<rect key="frame" x="277" y="20" width="46" height="30"/>
<state key="normal" title="Button">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="hamburgerAction:" destination="BYZ-38-t0r" eventType="touchUpInside" id="907-jE-9R4"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
<connections>
<outlet property="hamburgerButton" destination="NK4-aT-Mei" id="6tt-Mu-FC1"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
</document>

View File

@ -0,0 +1,68 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@ -0,0 +1,47 @@
<?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>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>com.yannickloriot.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>

View File

@ -0,0 +1,25 @@
//
// ViewController.swift
// DynamicButtonExample
//
// Created by Yannick LORIOT on 06/09/15.
// Copyright (c) 2015 Yannick LORIOT. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var hamburgerButton: DynamicButton!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
// MARK: - Action Methods
@IBAction func hamburgerAction(sender: AnyObject) {
hamburgerButton.setStyle(.Close, animated: true)
}
}

View File

@ -0,0 +1,36 @@
//
// DynamicButtonExampleTests.swift
// DynamicButtonExampleTests
//
// Created by Yannick LORIOT on 06/09/15.
// Copyright (c) 2015 Yannick LORIOT. All rights reserved.
//
import UIKit
import XCTest
class DynamicButtonExampleTests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
// This is an example of a functional test case.
XCTAssert(true, "Pass")
}
func testPerformanceExample() {
// This is an example of a performance test case.
self.measureBlock() {
// Put the code you want to measure the time of here.
}
}
}

View File

@ -0,0 +1,24 @@
<?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>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>com.yannickloriot.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>