Compare commits

..

No commits in common. "master" and "develop" have entirely different histories.

6 changed files with 29 additions and 25 deletions

View File

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

View File

@ -1,4 +1,3 @@
// //
// Package.swift // Package.swift
// FSPagerView // FSPagerView
@ -25,17 +24,11 @@
// THE SOFTWARE. // THE SOFTWARE.
// swift-tools-version:5.0
import PackageDescription import PackageDescription
let package = Package( let package = Package(
name: "FSPagerView", name: "FSPagerView",
platforms: [ dependencies : [],
.iOS(.v9) exclude: []
],
products: [
.library(name: "FSPagerView", targets: ["FSPagerView"]),
],
targets: [
.target(name: "FSPagerView", path: "Sources", exclude: ["FSPagerViewObjcCompat.h", "FSPagerViewObjcCompat.m"]),
]
) )

View File

@ -1,6 +1,6 @@
![fspagerview](https://cloud.githubusercontent.com/assets/5186464/24086370/45e7e8dc-0d49-11e7-86aa-139354fe00c5.jpg) ![fspagerview](https://cloud.githubusercontent.com/assets/5186464/24086370/45e7e8dc-0d49-11e7-86aa-139354fe00c5.jpg)
[![Languages](https://img.shields.io/badge/language-swift%205.0%20|%20objc-FF69B4.svg?style=plastic)](#) <br/> [![Languages](https://img.shields.io/badge/language-swift%204.2%20|%20objc-FF69B4.svg?style=plastic)](#) <br/>
[![Platform](https://img.shields.io/badge/platform-iOS%20|%20tvOS-blue.svg?style=plastic)](http://cocoadocs.org/docsets/FSPagerView) [![Platform](https://img.shields.io/badge/platform-iOS%20|%20tvOS-blue.svg?style=plastic)](http://cocoadocs.org/docsets/FSPagerView)
[![Version](https://img.shields.io/cocoapods/v/FSPagerView.svg?style=plastic)](http://cocoadocs.org/docsets/FSPagerView) [![Version](https://img.shields.io/cocoapods/v/FSPagerView.svg?style=plastic)](http://cocoadocs.org/docsets/FSPagerView)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=plastic)](https://github.com/Carthage/Carthage) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=plastic)](https://github.com/Carthage/Carthage)
@ -85,7 +85,7 @@ pagerView.interitemSpacing = 10
| ![1](https://cloud.githubusercontent.com/assets/5186464/22686429/1983b97e-ed5f-11e6-9a32-44c1830df7ac.gif) | | ![1](https://cloud.githubusercontent.com/assets/5186464/22686429/1983b97e-ed5f-11e6-9a32-44c1830df7ac.gif) |
```swift ```swift
pagerView.transformer = FSPagerViewTransformer(type: .crossFading) pagerView.transformer = FSPagerViewTransformer(type: .crossfading)
``` ```
--- ---
@ -96,7 +96,7 @@ pagerView.transformer = FSPagerViewTransformer(type: .crossFading)
| ![2](https://cloud.githubusercontent.com/assets/5186464/22686426/19830862-ed5f-11e6-90be-8fb1319cd125.gif) | | ![2](https://cloud.githubusercontent.com/assets/5186464/22686426/19830862-ed5f-11e6-90be-8fb1319cd125.gif) |
```swift ```swift
pagerView.transformer = FSPagerViewTransformer(type: .zoomOut) pagerView.transformer = FSPagerViewTransformer(type: .zoomout)
``` ```
--- ---

View File

@ -8,9 +8,11 @@
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()
@ -18,6 +20,7 @@ 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()
@ -25,6 +28,7 @@ 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()
@ -32,6 +36,7 @@ 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()
@ -39,6 +44,7 @@ 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()
@ -53,6 +59,7 @@ 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()

View File

@ -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
@objc open var minimumScale: CGFloat = 0.65 open var minimumScale: CGFloat = 0.65
@objc open var minimumAlpha: CGFloat = 0.6 open var minimumAlpha: CGFloat = 0.6
@objc @objc
public init(type: FSPagerViewTransformerType) { public init(type: FSPagerViewTransformerType) {

View File

@ -74,6 +74,7 @@ public protocol FSPagerViewDelegate: NSObjectProtocol {
} }
@IBDesignable
open class FSPagerView: UIView,UICollectionViewDataSource,UICollectionViewDelegate { open class FSPagerView: UIView,UICollectionViewDataSource,UICollectionViewDelegate {
// MARK: - Public properties // MARK: - Public properties
@ -93,6 +94,7 @@ 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()
@ -103,6 +105,7 @@ 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()
@ -110,6 +113,7 @@ 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()
@ -117,6 +121,7 @@ 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
@ -125,33 +130,39 @@ 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()
@ -159,6 +170,7 @@ 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 {
@ -500,8 +512,7 @@ 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 {
debugPrint("index \(index) is out of range [0...\(self.numberOfItems-1)]") fatalError("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 {