Skip to content

Commit a3b65a8

Browse files
author
Unknown
committed
Merge branch 'master' of github.com:Yalantis/Persei into feature/UICollectionView_example
# Conflicts: # Persei/Source/Core/StickyHeaderView.swift
2 parents 3c03569 + ce59e26 commit a3b65a8

File tree

6 files changed

+37
-21
lines changed

6 files changed

+37
-21
lines changed

.swift-version

-1
This file was deleted.

Example/Example.xcodeproj/project.pbxproj

+5-2
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@
280280
developmentRegion = en;
281281
hasScannedForEncodings = 0;
282282
knownRegions = (
283+
English,
283284
en,
284285
Base,
285286
);
@@ -397,11 +398,12 @@
397398
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
398399
GCC_WARN_UNUSED_FUNCTION = YES;
399400
GCC_WARN_UNUSED_VARIABLE = YES;
400-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
401+
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
401402
MTL_ENABLE_DEBUG_INFO = YES;
402403
ONLY_ACTIVE_ARCH = YES;
403404
SDKROOT = iphoneos;
404405
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
406+
SWIFT_VERSION = 5.0;
405407
};
406408
name = Debug;
407409
};
@@ -445,10 +447,11 @@
445447
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
446448
GCC_WARN_UNUSED_FUNCTION = YES;
447449
GCC_WARN_UNUSED_VARIABLE = YES;
448-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
450+
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
449451
MTL_ENABLE_DEBUG_INFO = NO;
450452
SDKROOT = iphoneos;
451453
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
454+
SWIFT_VERSION = 5.0;
452455
VALIDATE_PRODUCT = YES;
453456
};
454457
name = Release;

Persei.podspec

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |spec|
22
spec.name = "Persei"
3-
spec.version = '3.1.1'
4-
3+
spec.version = '4.0.0'
4+
spec.swift_version = '5.0'
55
spec.homepage = "https://github.com/Yalantis/Persei"
66
spec.summary = "Animated top menu for UITableView / UICollectionView / UIScrollView in Swift!"
77
spec.screenshot = "https://raw.githubusercontent.com/Yalantis/Persei/master/Assets/animation.gif"
@@ -10,8 +10,8 @@ Pod::Spec.new do |spec|
1010
spec.license = { :type => "MIT", :file => "LICENSE" }
1111
spec.social_media_url = "https://twitter.com/yalantis"
1212

13-
spec.platform = :ios, '9.0'
14-
spec.ios.deployment_target = '9.0'
13+
spec.platform = :ios, '11.0'
14+
spec.ios.deployment_target = '11.0'
1515

1616
spec.source = { :git => "https://github.com/Yalantis/Persei.git", :tag => spec.version }
1717

Persei.xcodeproj/project.pbxproj

+4-2
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,12 @@
260260
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
261261
GCC_WARN_UNUSED_FUNCTION = YES;
262262
GCC_WARN_UNUSED_VARIABLE = YES;
263-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
263+
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
264264
MTL_ENABLE_DEBUG_INFO = YES;
265265
ONLY_ACTIVE_ARCH = YES;
266266
SDKROOT = iphoneos;
267267
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
268+
SWIFT_VERSION = 5.0;
268269
TARGETED_DEVICE_FAMILY = "1,2";
269270
VERSIONING_SYSTEM = "apple-generic";
270271
VERSION_INFO_PREFIX = "";
@@ -312,10 +313,11 @@
312313
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
313314
GCC_WARN_UNUSED_FUNCTION = YES;
314315
GCC_WARN_UNUSED_VARIABLE = YES;
315-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
316+
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
316317
MTL_ENABLE_DEBUG_INFO = NO;
317318
SDKROOT = iphoneos;
318319
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
320+
SWIFT_VERSION = 5.0;
319321
TARGETED_DEVICE_FAMILY = "1,2";
320322
VALIDATE_PRODUCT = YES;
321323
VERSIONING_SYSTEM = "apple-generic";

Persei/Source/Core/StickyHeaderView.swift

+20-9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ private let DefaultContentHeight: CGFloat = 64
88
open class StickyHeaderView: UIView {
99

1010
// MARK: - Init
11+
1112
func commonInit() {
1213
translatesAutoresizingMaskIntoConstraints = false
1314

@@ -35,6 +36,7 @@ open class StickyHeaderView: UIView {
3536
}
3637

3738
// MARK: - View lifecycle
39+
3840
open override func willMove(toSuperview newSuperview: UIView?) {
3941
super.willMove(toSuperview: newSuperview)
4042

@@ -55,7 +57,7 @@ open class StickyHeaderView: UIView {
5557
view.addObserver(self, forKeyPath: #keyPath(UIScrollView.contentOffset), options: [.initial, .new], context: &ContentOffsetContext)
5658
view.panGestureRecognizer.addTarget(self, action: #selector(StickyHeaderView.handlePan))
5759
view.sendSubviewToBack(self)
58-
60+
5961
if needRevealed && !insetsApplied {
6062
addInsets()
6163
} else if insetsApplied {
@@ -113,9 +115,17 @@ open class StickyHeaderView: UIView {
113115
}
114116

115117
// MARK: - ScrollView
116-
private var scrollView: UIScrollView { return superview as! UIScrollView }
118+
119+
private var scrollView: UIScrollView {
120+
guard
121+
let scrollView = superview as? UIScrollView
122+
else { fatalError("superview is not UIScrollView") }
123+
124+
return scrollView
125+
}
117126

118127
// MARK: - KVO
128+
119129
open override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
120130
if context == &ContentOffsetContext {
121131
didScroll()
@@ -171,6 +181,7 @@ open class StickyHeaderView: UIView {
171181
}
172182

173183
// MARK: - Applyied Insets
184+
174185
private var appliedInsets: UIEdgeInsets = .zero
175186
private var insetsApplied: Bool {
176187
return appliedInsets != .zero
@@ -195,6 +206,7 @@ open class StickyHeaderView: UIView {
195206
}
196207

197208
// MARK: - ContentHeight
209+
198210
@IBInspectable open var contentHeight: CGFloat = DefaultContentHeight {
199211
didSet {
200212
if superview != nil {
@@ -204,9 +216,11 @@ open class StickyHeaderView: UIView {
204216
}
205217

206218
// MARK: - Threshold
219+
207220
@IBInspectable open var threshold: CGFloat = 0.3
208221

209222
// MARK: - Content Offset Hanlding
223+
210224
private func applyContentContainerTransform(_ progress: CGFloat) {
211225
var transform = CATransform3DIdentity
212226
transform.m34 = -1 / 500
@@ -245,6 +259,7 @@ open class StickyHeaderView: UIView {
245259
}
246260

247261
// MARK: - Layout
262+
248263
open override func layoutSubviews() {
249264
super.layoutSubviews()
250265

@@ -275,13 +290,9 @@ open class StickyHeaderView: UIView {
275290
}
276291

277292
open override func sizeThatFits(_: CGSize) -> CGSize {
278-
var height: CGFloat = 0
279-
if revealed {
280-
height = appliedInsets.top - scrollView.normalizedContentOffset.y
281-
} else {
282-
height = scrollView.normalizedContentOffset.y * -1
283-
}
284-
293+
let revealedHeight: CGFloat = appliedInsets.top - scrollView.normalizedContentOffset.y
294+
let collapsedHeight: CGFloat = scrollView.normalizedContentOffset.y * -1
295+
let height: CGFloat = revealed ? revealedHeight : collapsedHeight
285296
let output = CGSize(width: scrollView.bounds.width, height: max(height, 0))
286297

287298
return output

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ Check this [project on Behance](https://www.behance.net/gallery/20411445/Mobile-
1919
| 1.x | 1.1 |
2020
| 2.x | 2.0 |
2121
| 3.x | 3.0 |
22-
| **4.x** | **3.1** |
22+
| 4.x | 3.1|
23+
| **5.x** | **4.0** |
2324

2425
## Installation
2526

@@ -28,13 +29,13 @@ Check this [project on Behance](https://www.behance.net/gallery/20411445/Mobile-
2829
```ruby
2930
use_frameworks!
3031

31-
pod 'Persei', '~> 3.0'
32+
pod 'Persei', '~> 4.0'
3233
```
3334

3435
### [Carthage](http://github.com/Carthage/Carthage)
3536

3637
```ruby
37-
github "Yalantis/Persei" ~> 3.0
38+
github "Yalantis/Persei" ~> 4.0
3839
```
3940

4041
### Manual Installation

0 commit comments

Comments
 (0)