Skip to content

Commit f02ac82

Browse files
committed
First pass at AutoLayout for variable height sticky views.
1 parent 04d827b commit f02ac82

File tree

10 files changed

+181
-147
lines changed

10 files changed

+181
-147
lines changed

Example/StickyHeaderTabController.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@
517517
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
518518
GCC_WARN_UNUSED_FUNCTION = YES;
519519
GCC_WARN_UNUSED_VARIABLE = YES;
520-
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
520+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
521521
MTL_ENABLE_DEBUG_INFO = YES;
522522
ONLY_ACTIVE_ARCH = YES;
523523
SDKROOT = iphoneos;
@@ -557,7 +557,7 @@
557557
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
558558
GCC_WARN_UNUSED_FUNCTION = YES;
559559
GCC_WARN_UNUSED_VARIABLE = YES;
560-
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
560+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
561561
MTL_ENABLE_DEBUG_INFO = NO;
562562
SDKROOT = iphoneos;
563563
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";

Example/StickyHeaderTabController/ExampleTabController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class ExampleTabController: StickyHeaderTabController {
3939
// Private Methods
4040

4141
fileprivate func updateAvatarSize() {
42-
let maxValue = exampleHeader.headerHeight
42+
let maxValue = exampleHeader.bounds.height
4343
let minValue = exampleHeader.pinnedHeight
4444
let currentValue = exampleHero.frame.origin.y
4545

Example/StickyHeaderTabController/StickyViews/ExampleStickyHeaderView.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ class ExampleStickyHeaderView: StickyHeaderView {
1313

1414
// MARK: - Properties
1515

16+
override public var pinnedHeight: CGFloat {
17+
return 60.0
18+
}
19+
1620
var percentVisibleName: CGFloat = 0.0 {
1721
didSet {
1822
if percentVisibleName != oldValue {
@@ -46,6 +50,10 @@ class ExampleStickyHeaderView: StickyHeaderView {
4650
// MARK: - Setup
4751

4852
private func commonSetup() {
53+
let heightConstraint = heightAnchor.constraint(equalToConstant: 170.0)
54+
heightConstraint.priority = 500.0
55+
heightConstraint.isActive = true
56+
4957
setUpAvatar()
5058
setUpBlur()
5159
setUpNameLabel()

Example/StickyHeaderTabController/StickyViews/ExampleStickyHeroView.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import UIKit
1010
import StickyHeaderTabController
1111

12-
class ExampleStickyHeroView: StickyHeaderHeroView {
12+
class ExampleStickyHeroView: UIView {
1313

1414
// MARK: - Properties
1515

@@ -41,6 +41,8 @@ class ExampleStickyHeroView: StickyHeaderHeroView {
4141
// MARK: - Setup
4242

4343
private func commonSetup() {
44+
heightAnchor.constraint(equalToConstant: 200.0).isActive = true
45+
4446
backgroundColor = UIColor(red: 0.0, green: 0.4, blue: 0.4, alpha: 1.0)
4547

4648
setUpAvatar()

StickyHeaderTabController.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = 'StickyHeaderTabController'
11-
s.version = '0.1.0'
11+
s.version = '0.0.1'
1212
s.summary = 'Tabbed content controller with sticky header and hero.'
1313

1414
# This description is used to generate tags and improve search results.
@@ -28,7 +28,7 @@ Tabbed content controller with sticky header and hero.
2828
s.source = { :git => 'https://github.com/bchrobot/StickyHeaderTabController.git', :tag => s.version.to_s }
2929
s.social_media_url = 'https://twitter.com/bchrobot'
3030

31-
s.ios.deployment_target = '8.0'
31+
s.ios.deployment_target = '9.0'
3232

3333
s.source_files = 'StickyHeaderTabController/Classes/**/*'
3434

0 commit comments

Comments
 (0)