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
37 changes: 30 additions & 7 deletions TZStackView.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = "Tom van Zummeren";
TargetAttributes = {
5F50E36345E94CFC65ED7270 = {
Expand All @@ -275,6 +275,7 @@
};
A45441BE1B9B6D71002452BA = {
CreatedOnToolsVersion = 7.0;
LastSwiftMigration = 0900;
};
};
};
Expand Down Expand Up @@ -381,14 +382,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = 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_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand All @@ -397,6 +404,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/**";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
Expand Down Expand Up @@ -428,14 +436,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = 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_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand All @@ -444,6 +458,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/**";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand All @@ -465,18 +480,20 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = TZStackViewDemo/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "nl.tomvanzummeren.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
5F50E86DCFE460998B6EFE66 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/TZStackViewDemo.app/TZStackViewDemo";
DEVELOPMENT_TEAM = "";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
Expand All @@ -485,7 +502,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "nl.tomvanzummeren.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUNDLE_LOADER)";
};
name = Release;
Expand All @@ -494,6 +511,7 @@
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/TZStackViewDemo.app/TZStackViewDemo";
DEVELOPMENT_TEAM = "";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
Expand All @@ -502,7 +520,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "nl.tomvanzummeren.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUNDLE_LOADER)";
};
name = Debug;
Expand All @@ -512,11 +530,12 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = TZStackViewDemo/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "nl.tomvanzummeren.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -531,6 +550,7 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_SEARCH_PATHS = "";
INFOPLIST_FILE = TZStackView/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
Expand All @@ -539,7 +559,8 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -556,14 +577,16 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_SEARCH_PATHS = "";
INFOPLIST_FILE = TZStackView/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = nl.tomvanzummeren.TZStackView;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
Expand All @@ -36,6 +37,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
4 changes: 2 additions & 2 deletions TZStackView/TZStackView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public class TZStackView: UIView {
addHiddenListener(arrangedSubview)
}

func hiddenAnimationStopped() {
@objc func hiddenAnimationStopped() {
var queueEntriesToRemove = [TZAnimationDidStopQueueEntry]()
for entry in animationDidStopQueueEntries {
let view = entry.view
Expand Down Expand Up @@ -595,7 +595,7 @@ public class TZStackView: UIView {
let attribute2 = attr2 != nil ? attr2! : attr1

let constraint = NSLayoutConstraint(item: view1, attribute: attr1, relatedBy: relation, toItem: view2, attribute: attribute2, multiplier: multiplier, constant: c)
constraint.priority = priority
constraint.priority = UILayoutPriority(rawValue: priority)
return constraint
}

Expand Down
2 changes: 1 addition & 1 deletion TZStackViewDemo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
//Appearance proxy for the UISegmentedControl font
UISegmentedControl.appearance().setTitleTextAttributes(
[NSFontAttributeName:UIFont(name: "HelveticaNeue-Light", size:10.0)!],
[NSAttributedStringKey.font:UIFont(name: "HelveticaNeue-Light", size:10.0)!],
for: UIControlState())

//Launch the application
Expand Down
2 changes: 1 addition & 1 deletion TZStackViewDemo/ExplicitIntrinsicContentSizeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ExplicitIntrinsicContentSizeView: UIView {
isUserInteractionEnabled = true
}

func tap() {
@objc func tap() {
UIView.animate(withDuration: 0.6, delay: 0, usingSpringWithDamping: 0.7, initialSpringVelocity: 0, options: .allowUserInteraction, animations: {
self.isHidden = true
}, completion: nil)
Expand Down
15 changes: 15 additions & 0 deletions TZStackViewDemo/Images.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
Expand Down Expand Up @@ -29,6 +39,11 @@
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
Expand Down
24 changes: 12 additions & 12 deletions TZStackViewDemo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,28 @@ class ViewController: UIViewController {
instructionLabel.text = "Tap any of the boxes to set hidden=true"
instructionLabel.textColor = UIColor.white
instructionLabel.numberOfLines = 0
instructionLabel.setContentCompressionResistancePriority(900, for: .horizontal)
instructionLabel.setContentHuggingPriority(1000, for: .vertical)
instructionLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal)
instructionLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 1000), for: .vertical)
view.addSubview(instructionLabel)

resetButton.translatesAutoresizingMaskIntoConstraints = false
resetButton.setTitle("Reset", for: UIControlState())
resetButton.addTarget(self, action: #selector(ViewController.reset), for: .touchUpInside)
resetButton.setContentCompressionResistancePriority(1000, for: .horizontal)
resetButton.setContentHuggingPriority(1000, for: .horizontal)
resetButton.setContentHuggingPriority(1000, for: .vertical)
resetButton.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 1000), for: .horizontal)
resetButton.setContentHuggingPriority(UILayoutPriority(rawValue: 1000), for: .horizontal)
resetButton.setContentHuggingPriority(UILayoutPriority(rawValue: 1000), for: .vertical)
view.addSubview(resetButton)

axisSegmentedControl = UISegmentedControl(items: ["Vertical", "Horizontal"])
axisSegmentedControl.selectedSegmentIndex = 0
axisSegmentedControl.addTarget(self, action: #selector(ViewController.axisChanged(_:)), for: .valueChanged)
axisSegmentedControl.setContentCompressionResistancePriority(900, for: .horizontal)
axisSegmentedControl.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 900), for: .horizontal)
axisSegmentedControl.tintColor = UIColor.lightGray

alignmentSegmentedControl = UISegmentedControl(items: ["Fill", "Center", "Leading", "Top", "Trailing", "Bottom", "FirstBaseline"])
alignmentSegmentedControl.selectedSegmentIndex = 0
alignmentSegmentedControl.addTarget(self, action: #selector(ViewController.alignmentChanged(_:)), for: .valueChanged)
alignmentSegmentedControl.setContentCompressionResistancePriority(1000, for: .horizontal)
alignmentSegmentedControl.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 1000), for: .horizontal)
alignmentSegmentedControl.tintColor = UIColor.lightGray

distributionSegmentedControl = UISegmentedControl(items: ["Fill", "FillEqually", "FillProportionally", "EqualSpacing", "EqualCentering"])
Expand All @@ -77,7 +77,7 @@ class ViewController: UIViewController {
controlsLayoutContainer.axis = .vertical
controlsLayoutContainer.translatesAutoresizingMaskIntoConstraints = false
controlsLayoutContainer.spacing = 5
controlsLayoutContainer.setContentHuggingPriority(1000, for: .vertical)
controlsLayoutContainer.setContentHuggingPriority(UILayoutPriority(rawValue: 1000), for: .vertical)
view.addSubview(controlsLayoutContainer)

let views: [String:AnyObject] = [
Expand Down Expand Up @@ -122,7 +122,7 @@ class ViewController: UIViewController {

//MARK: - Button Actions
//--------------------------------------------------------------------------
func reset() {
@objc func reset() {
UIView.animate(withDuration: 0.6, delay: 0, usingSpringWithDamping: 0.7, initialSpringVelocity: 0, options: .allowUserInteraction, animations: {
for view in self.tzStackView.arrangedSubviews {
view.isHidden = false
Expand All @@ -133,7 +133,7 @@ class ViewController: UIViewController {

//MARK: - Segmented Control Actions
//--------------------------------------------------------------------------
func axisChanged(_ sender: UISegmentedControl) {
@objc func axisChanged(_ sender: UISegmentedControl) {
switch sender.selectedSegmentIndex {
case 0:
tzStackView.axis = .vertical
Expand All @@ -142,7 +142,7 @@ class ViewController: UIViewController {
}
}

func alignmentChanged(_ sender: UISegmentedControl) {
@objc func alignmentChanged(_ sender: UISegmentedControl) {
switch sender.selectedSegmentIndex {
case 0:
tzStackView.alignment = .fill
Expand All @@ -162,7 +162,7 @@ class ViewController: UIViewController {
tzStackView.setNeedsUpdateConstraints()
}

func distributionChanged(_ sender: UISegmentedControl) {
@objc func distributionChanged(_ sender: UISegmentedControl) {
switch sender.selectedSegmentIndex {
case 0:
tzStackView.distribution = .fill
Expand Down
4 changes: 2 additions & 2 deletions TZStackViewTests/TZStackViewTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ class TZStackViewTestCase: XCTestCase {
return false
}
if layoutConstraint1.priority != layoutConstraint2.priority {
if layoutConstraint1.priority < 100 || layoutConstraint1.priority > 150
|| layoutConstraint2.priority < 100 || layoutConstraint2.priority > 150 {
if layoutConstraint1.priority.rawValue < 100 || layoutConstraint1.priority.rawValue > 150
|| layoutConstraint2.priority.rawValue < 100 || layoutConstraint2.priority.rawValue > 150 {
return false
}
}
Expand Down
Loading