Compare commits
24 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
795308668c | |
|
|
f3e95c90ec | |
|
|
320b4f57bb | |
|
|
0df6070810 | |
|
|
c1718fb5c1 | |
|
|
9bebb56fc1 | |
|
|
15a64b5c3f | |
|
|
bd38b12314 | |
|
|
00dd915191 | |
|
|
aa652bfe05 | |
|
|
68b82f91e1 | |
|
|
3acbd3e987 | |
|
|
0560602b2f | |
|
|
1c2aaef6bf | |
|
|
977ac1f5cf | |
|
|
a67e26d75d | |
|
|
fba5e9ea70 | |
|
|
d25867705f | |
|
|
ca03ae6475 | |
|
|
7a1eac8f0a | |
|
|
6b4a11fa78 | |
|
|
e61151be2f | |
|
|
2f16b6f98f | |
|
|
e535eb1a81 |
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Workspace
|
||||||
|
version = "1.0">
|
||||||
|
<FileRef
|
||||||
|
location = "self:">
|
||||||
|
</FileRef>
|
||||||
|
</Workspace>
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
//
|
//
|
||||||
// Package.swift
|
// Package.swift
|
||||||
// FSPagerView
|
// FSPagerView
|
||||||
|
|
@ -24,11 +25,17 @@
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
// swift-tools-version:5.0
|
|
||||||
import PackageDescription
|
import PackageDescription
|
||||||
|
|
||||||
let package = Package(
|
let package = Package(
|
||||||
name: "FSPagerView",
|
name: "FSPagerView",
|
||||||
dependencies : [],
|
platforms: [
|
||||||
exclude: []
|
.iOS(.v9)
|
||||||
|
],
|
||||||
|
products: [
|
||||||
|
.library(name: "FSPagerView", targets: ["FSPagerView"]),
|
||||||
|
],
|
||||||
|
targets: [
|
||||||
|
.target(name: "FSPagerView", path: "Sources", exclude: ["FSPagerViewObjcCompat.h", "FSPagerViewObjcCompat.m"]),
|
||||||
|
]
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||

|

|
||||||
|
|
||||||
[](#) <br/>
|
[](#) <br/>
|
||||||
[](http://cocoadocs.org/docsets/FSPagerView)
|
[](http://cocoadocs.org/docsets/FSPagerView)
|
||||||
[](http://cocoadocs.org/docsets/FSPagerView)
|
[](http://cocoadocs.org/docsets/FSPagerView)
|
||||||
[](https://github.com/Carthage/Carthage)
|
[](https://github.com/Carthage/Carthage)
|
||||||
|
|
@ -85,7 +85,7 @@ pagerView.interitemSpacing = 10
|
||||||
|  |
|
|  |
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
pagerView.transformer = FSPagerViewTransformer(type: .crossfading)
|
pagerView.transformer = FSPagerViewTransformer(type: .crossFading)
|
||||||
```
|
```
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
@ -96,7 +96,7 @@ pagerView.transformer = FSPagerViewTransformer(type: .crossfading)
|
||||||
|  |
|
|  |
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
pagerView.transformer = FSPagerViewTransformer(type: .zoomout)
|
pagerView.transformer = FSPagerViewTransformer(type: .zoomOut)
|
||||||
```
|
```
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,9 @@
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
@IBDesignable
|
|
||||||
open class FSPageControl: UIControl {
|
open class FSPageControl: UIControl {
|
||||||
|
|
||||||
/// The number of page indicators of the page control. Default is 0.
|
/// The number of page indicators of the page control. Default is 0.
|
||||||
@IBInspectable
|
|
||||||
open var numberOfPages: Int = 0 {
|
open var numberOfPages: Int = 0 {
|
||||||
didSet {
|
didSet {
|
||||||
self.setNeedsCreateIndicators()
|
self.setNeedsCreateIndicators()
|
||||||
|
|
@ -20,7 +18,6 @@ open class FSPageControl: UIControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The current page, highlighted by the page control. Default is 0.
|
/// The current page, highlighted by the page control. Default is 0.
|
||||||
@IBInspectable
|
|
||||||
open var currentPage: Int = 0 {
|
open var currentPage: Int = 0 {
|
||||||
didSet {
|
didSet {
|
||||||
self.setNeedsUpdateIndicators()
|
self.setNeedsUpdateIndicators()
|
||||||
|
|
@ -28,7 +25,6 @@ open class FSPageControl: UIControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The spacing to use of page indicators in the page control.
|
/// The spacing to use of page indicators in the page control.
|
||||||
@IBInspectable
|
|
||||||
open var itemSpacing: CGFloat = 6 {
|
open var itemSpacing: CGFloat = 6 {
|
||||||
didSet {
|
didSet {
|
||||||
self.setNeedsUpdateIndicators()
|
self.setNeedsUpdateIndicators()
|
||||||
|
|
@ -36,7 +32,6 @@ open class FSPageControl: UIControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The spacing to use between page indicators in the page control.
|
/// The spacing to use between page indicators in the page control.
|
||||||
@IBInspectable
|
|
||||||
open var interitemSpacing: CGFloat = 6 {
|
open var interitemSpacing: CGFloat = 6 {
|
||||||
didSet {
|
didSet {
|
||||||
self.setNeedsLayout()
|
self.setNeedsLayout()
|
||||||
|
|
@ -44,7 +39,6 @@ open class FSPageControl: UIControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The distance that the page indicators is inset from the enclosing page control.
|
/// The distance that the page indicators is inset from the enclosing page control.
|
||||||
@IBInspectable
|
|
||||||
open var contentInsets: UIEdgeInsets = .zero {
|
open var contentInsets: UIEdgeInsets = .zero {
|
||||||
didSet {
|
didSet {
|
||||||
self.setNeedsLayout()
|
self.setNeedsLayout()
|
||||||
|
|
@ -59,7 +53,6 @@ open class FSPageControl: UIControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Hide the indicator if there is only one page. default is NO
|
/// Hide the indicator if there is only one page. default is NO
|
||||||
@IBInspectable
|
|
||||||
open var hidesForSinglePage: Bool = false {
|
open var hidesForSinglePage: Bool = false {
|
||||||
didSet {
|
didSet {
|
||||||
self.setNeedsUpdateIndicators()
|
self.setNeedsUpdateIndicators()
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,8 @@ open class FSPagerViewTransformer: NSObject {
|
||||||
open internal(set) weak var pagerView: FSPagerView?
|
open internal(set) weak var pagerView: FSPagerView?
|
||||||
open internal(set) var type: FSPagerViewTransformerType
|
open internal(set) var type: FSPagerViewTransformerType
|
||||||
|
|
||||||
open var minimumScale: CGFloat = 0.65
|
@objc open var minimumScale: CGFloat = 0.65
|
||||||
open var minimumAlpha: CGFloat = 0.6
|
@objc open var minimumAlpha: CGFloat = 0.6
|
||||||
|
|
||||||
@objc
|
@objc
|
||||||
public init(type: FSPagerViewTransformerType) {
|
public init(type: FSPagerViewTransformerType) {
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,6 @@ public protocol FSPagerViewDelegate: NSObjectProtocol {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@IBDesignable
|
|
||||||
open class FSPagerView: UIView,UICollectionViewDataSource,UICollectionViewDelegate {
|
open class FSPagerView: UIView,UICollectionViewDataSource,UICollectionViewDelegate {
|
||||||
|
|
||||||
// MARK: - Public properties
|
// MARK: - Public properties
|
||||||
|
|
@ -94,7 +93,6 @@ open class FSPagerView: UIView,UICollectionViewDataSource,UICollectionViewDelega
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The time interval of automatic sliding. 0 means disabling automatic sliding. Default is 0.
|
/// The time interval of automatic sliding. 0 means disabling automatic sliding. Default is 0.
|
||||||
@IBInspectable
|
|
||||||
open var automaticSlidingInterval: CGFloat = 0.0 {
|
open var automaticSlidingInterval: CGFloat = 0.0 {
|
||||||
didSet {
|
didSet {
|
||||||
self.cancelTimer()
|
self.cancelTimer()
|
||||||
|
|
@ -105,7 +103,6 @@ open class FSPagerView: UIView,UICollectionViewDataSource,UICollectionViewDelega
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The spacing to use between items in the pager view. Default is 0.
|
/// The spacing to use between items in the pager view. Default is 0.
|
||||||
@IBInspectable
|
|
||||||
open var interitemSpacing: CGFloat = 0 {
|
open var interitemSpacing: CGFloat = 0 {
|
||||||
didSet {
|
didSet {
|
||||||
self.collectionViewLayout.forceInvalidate()
|
self.collectionViewLayout.forceInvalidate()
|
||||||
|
|
@ -113,7 +110,6 @@ open class FSPagerView: UIView,UICollectionViewDataSource,UICollectionViewDelega
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The item size of the pager view. When the value of this property is FSPagerView.automaticSize, the items fill the entire visible area of the pager view. Default is FSPagerView.automaticSize.
|
/// The item size of the pager view. When the value of this property is FSPagerView.automaticSize, the items fill the entire visible area of the pager view. Default is FSPagerView.automaticSize.
|
||||||
@IBInspectable
|
|
||||||
open var itemSize: CGSize = automaticSize {
|
open var itemSize: CGSize = automaticSize {
|
||||||
didSet {
|
didSet {
|
||||||
self.collectionViewLayout.forceInvalidate()
|
self.collectionViewLayout.forceInvalidate()
|
||||||
|
|
@ -121,7 +117,6 @@ open class FSPagerView: UIView,UICollectionViewDataSource,UICollectionViewDelega
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A Boolean value indicates that whether the pager view has infinite items. Default is false.
|
/// A Boolean value indicates that whether the pager view has infinite items. Default is false.
|
||||||
@IBInspectable
|
|
||||||
open var isInfinite: Bool = false {
|
open var isInfinite: Bool = false {
|
||||||
didSet {
|
didSet {
|
||||||
self.collectionViewLayout.needsReprepare = true
|
self.collectionViewLayout.needsReprepare = true
|
||||||
|
|
@ -130,39 +125,33 @@ open class FSPagerView: UIView,UICollectionViewDataSource,UICollectionViewDelega
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An unsigned integer value that determines the deceleration distance of the pager view, which indicates the number of passing items during the deceleration. When the value of this property is FSPagerView.automaticDistance, the actual 'distance' is automatically calculated according to the scrolling speed of the pager view. Default is 1.
|
/// An unsigned integer value that determines the deceleration distance of the pager view, which indicates the number of passing items during the deceleration. When the value of this property is FSPagerView.automaticDistance, the actual 'distance' is automatically calculated according to the scrolling speed of the pager view. Default is 1.
|
||||||
@IBInspectable
|
|
||||||
open var decelerationDistance: UInt = 1
|
open var decelerationDistance: UInt = 1
|
||||||
|
|
||||||
/// A Boolean value that determines whether scrolling is enabled.
|
/// A Boolean value that determines whether scrolling is enabled.
|
||||||
@IBInspectable
|
|
||||||
open var isScrollEnabled: Bool {
|
open var isScrollEnabled: Bool {
|
||||||
set { self.collectionView.isScrollEnabled = newValue }
|
set { self.collectionView.isScrollEnabled = newValue }
|
||||||
get { return self.collectionView.isScrollEnabled }
|
get { return self.collectionView.isScrollEnabled }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A Boolean value that controls whether the pager view bounces past the edge of content and back again.
|
/// A Boolean value that controls whether the pager view bounces past the edge of content and back again.
|
||||||
@IBInspectable
|
|
||||||
open var bounces: Bool {
|
open var bounces: Bool {
|
||||||
set { self.collectionView.bounces = newValue }
|
set { self.collectionView.bounces = newValue }
|
||||||
get { return self.collectionView.bounces }
|
get { return self.collectionView.bounces }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A Boolean value that determines whether bouncing always occurs when horizontal scrolling reaches the end of the content view.
|
/// A Boolean value that determines whether bouncing always occurs when horizontal scrolling reaches the end of the content view.
|
||||||
@IBInspectable
|
|
||||||
open var alwaysBounceHorizontal: Bool {
|
open var alwaysBounceHorizontal: Bool {
|
||||||
set { self.collectionView.alwaysBounceHorizontal = newValue }
|
set { self.collectionView.alwaysBounceHorizontal = newValue }
|
||||||
get { return self.collectionView.alwaysBounceHorizontal }
|
get { return self.collectionView.alwaysBounceHorizontal }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A Boolean value that determines whether bouncing always occurs when vertical scrolling reaches the end of the content view.
|
/// A Boolean value that determines whether bouncing always occurs when vertical scrolling reaches the end of the content view.
|
||||||
@IBInspectable
|
|
||||||
open var alwaysBounceVertical: Bool {
|
open var alwaysBounceVertical: Bool {
|
||||||
set { self.collectionView.alwaysBounceVertical = newValue }
|
set { self.collectionView.alwaysBounceVertical = newValue }
|
||||||
get { return self.collectionView.alwaysBounceVertical }
|
get { return self.collectionView.alwaysBounceVertical }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A Boolean value that controls whether the infinite loop is removed if there is only one item. Default is false.
|
/// A Boolean value that controls whether the infinite loop is removed if there is only one item. Default is false.
|
||||||
@IBInspectable
|
|
||||||
open var removesInfiniteLoopForSingleItem: Bool = false {
|
open var removesInfiniteLoopForSingleItem: Bool = false {
|
||||||
didSet {
|
didSet {
|
||||||
self.reloadData()
|
self.reloadData()
|
||||||
|
|
@ -170,7 +159,6 @@ open class FSPagerView: UIView,UICollectionViewDataSource,UICollectionViewDelega
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The background view of the pager view.
|
/// The background view of the pager view.
|
||||||
@IBInspectable
|
|
||||||
open var backgroundView: UIView? {
|
open var backgroundView: UIView? {
|
||||||
didSet {
|
didSet {
|
||||||
if let backgroundView = self.backgroundView {
|
if let backgroundView = self.backgroundView {
|
||||||
|
|
@ -512,7 +500,8 @@ open class FSPagerView: UIView,UICollectionViewDataSource,UICollectionViewDelega
|
||||||
@objc(scrollToItemAtIndex:animated:)
|
@objc(scrollToItemAtIndex:animated:)
|
||||||
open func scrollToItem(at index: Int, animated: Bool) {
|
open func scrollToItem(at index: Int, animated: Bool) {
|
||||||
guard index < self.numberOfItems else {
|
guard index < self.numberOfItems else {
|
||||||
fatalError("index \(index) is out of range [0...\(self.numberOfItems-1)]")
|
debugPrint("index \(index) is out of range [0...\(self.numberOfItems-1)]")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
let indexPath = { () -> IndexPath in
|
let indexPath = { () -> IndexPath in
|
||||||
if let indexPath = self.possibleTargetingIndexPath, indexPath.item == index {
|
if let indexPath = self.possibleTargetingIndexPath, indexPath.item == index {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue