From f72e492bab7afdb95d0404456abdbe311fcd69e0 Mon Sep 17 00:00:00 2001 From: WenchaoD Date: Tue, 21 Feb 2017 21:21:11 +0800 Subject: [PATCH] Update documentation. --- FSPagerView.podspec | 2 +- FSPagerView/FSPageControl.swift | 23 +++++++++++++++++++- FSPagerView/FSPageViewLayout.swift | 13 ++++++----- FSPagerView/FSPagerView.swift | 35 ++++++++++++++++++++++++++++-- FSPagerView/FSPagerViewCell.swift | 15 ++++++++----- README-OBJECTIVE-C.md | 5 ++++- README.md | 4 +++- 7 files changed, 79 insertions(+), 18 deletions(-) diff --git a/FSPagerView.podspec b/FSPagerView.podspec index 961a31c..f9b00c9 100644 --- a/FSPagerView.podspec +++ b/FSPagerView.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "FSPagerView" - s.version = "0.1.1" + s.version = "0.2.0" s.summary = "FSPagerView is an elegant Screen Slide Library for making Banner、Product Show、Welcome/Guide Pages、Screen/ViewController Sliders." s.homepage = "https://github.com/WenchaoD/FSPagerView" diff --git a/FSPagerView/FSPageControl.swift b/FSPagerView/FSPageControl.swift index ab309cb..97ff55c 100644 --- a/FSPagerView/FSPageControl.swift +++ b/FSPagerView/FSPageControl.swift @@ -142,6 +142,10 @@ open class FSPageControl: UIControl { } /// Sets the stroke color for page indicators to use for the specified state. (selected/normal). + /// + /// - Parameters: + /// - strokeColor: The stroke color to use for the specified state. + /// - state: The state that uses the specified stroke color. @objc(setStrokeColor:forState:) open func setStrokeColor(_ strokeColor: UIColor?, for state: UIControlState) { guard self.strokeColors[state] != strokeColor else { @@ -152,6 +156,10 @@ open class FSPageControl: UIControl { } /// Sets the fill color for page indicators to use for the specified state. (selected/normal). + /// + /// - Parameters: + /// - fillColor: The fill color to use for the specified state. + /// - state: The state that uses the specified fill color. @objc(setFillColor:forState:) open func setFillColor(_ fillColor: UIColor?, for state: UIControlState) { guard self.fillColors[state] != fillColor else { @@ -162,6 +170,10 @@ open class FSPageControl: UIControl { } /// Sets the image for page indicators to use for the specified state. (selected/normal). + /// + /// - Parameters: + /// - image: The image to use for the specified state. + /// - state: The state that uses the specified image. @objc(setImage:forState:) open func setImage(_ image: UIImage?, for state: UIControlState) { guard self.images[state] != image else { @@ -171,8 +183,13 @@ open class FSPageControl: UIControl { self.setNeedsUpdateIndicators() } - /// Sets the alpha value for page indicators to use for the specified state. (selected/normal). @objc(setAlpha:forState:) + + /// Sets the alpha value for page indicators to use for the specified state. (selected/normal). + /// + /// - Parameters: + /// - alpha: The alpha value to use for the specified state. + /// - state: The state that uses the specified alpha. open func setAlpha(_ alpha: CGFloat, for state: UIControlState) { guard self.alphas[state] != alpha else { return @@ -182,6 +199,10 @@ open class FSPageControl: UIControl { } /// Sets the path for page indicators to use for the specified state. (selected/normal). + /// + /// - Parameters: + /// - path: The path to use for the specified state. + /// - state: The state that uses the specified path. @objc(setPath:forState:) open func setPath(_ path: UIBezierPath?, for state: UIControlState) { guard self.paths[state] != path else { diff --git a/FSPagerView/FSPageViewLayout.swift b/FSPagerView/FSPageViewLayout.swift index 17b8ce3..22c904c 100644 --- a/FSPagerView/FSPageViewLayout.swift +++ b/FSPagerView/FSPageViewLayout.swift @@ -187,12 +187,7 @@ class FSPagerViewLayout: UICollectionViewLayout { return frame } - // MARK:- Private functions - - fileprivate func commonInit() { - NotificationCenter.default.addObserver(self, selector: #selector(didReceiveNotification(notification:)), name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil) - } - + // MARK:- Notification @objc fileprivate func didReceiveNotification(notification: Notification) { if self.pagerView?.itemSize == .zero { @@ -200,6 +195,12 @@ class FSPagerViewLayout: UICollectionViewLayout { } } + // MARK:- Private functions + + fileprivate func commonInit() { + NotificationCenter.default.addObserver(self, selector: #selector(didReceiveNotification(notification:)), name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil) + } + fileprivate func adjustCollectionViewBounds() { guard let collectionView = self.collectionView, let pagerView = self.pagerView else { return diff --git a/FSPagerView/FSPagerView.swift b/FSPagerView/FSPagerView.swift index eac3b7f..de5cc98 100644 --- a/FSPagerView/FSPagerView.swift +++ b/FSPagerView/FSPagerView.swift @@ -5,6 +5,10 @@ // Created by Wenchao Ding on 17/12/2016. // Copyright © 2016 Wenchao Ding. All rights reserved. // +// https://github.com/WenchaoD +// +// FSPagerView is an elegant Screen Slide Library implemented primarily with UICollectionView. It is extremely helpful for making Banner、Product Show、Welcome/Guide Pages、Screen/ViewController Sliders. +// import UIKit @@ -122,7 +126,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? { didSet { @@ -136,7 +140,7 @@ open class FSPagerView: UIView,UICollectionViewDataSource,UICollectionViewDelega } } - /// The transformer of the pager view + /// The transformer of the pager view. open var transformer: FSPagerViewTransformer? { didSet { self.transformer?.pagerView = self @@ -352,6 +356,11 @@ open class FSPagerView: UIView,UICollectionViewDataSource,UICollectionViewDelega // MARK: - Public functions + /// Register a class for use in creating new pager view cells. + /// + /// - Parameters: + /// - cellClass: The class of a cell that you want to use in the pager view. + /// - identifier: The reuse identifier to associate with the specified class. This parameter must not be nil and must not be an empty string. @objc(registerClass:forCellWithReuseIdentifier:) open func register(_ cellClass: Swift.AnyClass?, forCellWithReuseIdentifier identifier: String) { guard let cellClass = cellClass, cellClass.isSubclass(of: FSPagerViewCell.self) else { @@ -360,6 +369,12 @@ open class FSPagerView: UIView,UICollectionViewDataSource,UICollectionViewDelega self.collectionView.register(cellClass, forCellWithReuseIdentifier: identifier) } + /// Returns a reusable cell object located by its identifier + /// + /// - Parameters: + /// - identifier: The reuse identifier for the specified cell. This parameter must not be nil. + /// - index: The index specifying the location of the cell. + /// - Returns: A valid FSPagerViewCell object. @objc(dequeueReusableCellWithReuseIdentifier:atIndex:) open func dequeueReusableCell(withReuseIdentifier identifier: String, at index: Int) -> FSPagerViewCell { let indexPath = IndexPath(item: index, section: self.dequeingSection) @@ -367,23 +382,39 @@ open class FSPagerView: UIView,UICollectionViewDataSource,UICollectionViewDelega return cell } + /// Reloads all of the data for the collection view. @objc(reloadData) open func reloadData() { self.collectionView.reloadData() } + /// Selects the item at the specified index and optionally scrolls it into view. + /// + /// - Parameters: + /// - index: The index path of the item to select. + /// - animated: Specify true to animate the change in the selection or false to make the change without animating it. @objc(selectItemAtIndex:animated:) open func selectItem(at index: Int, animated: Bool) { let indexPath = self.nearbyIndexPath(for: index) self.collectionView.selectItem(at: indexPath, animated: animated, scrollPosition: .centeredHorizontally) } + /// Deselects the item at the specified index. + /// + /// - Parameters: + /// - index: The index of the item to deselect. + /// - animated: Specify true to animate the change in the selection or false to make the change without animating it. @objc(deselectItemAtIndex:animated:) open func deselectItem(at index: Int, animated: Bool) { let indexPath = self.nearbyIndexPath(for: index) self.collectionView.deselectItem(at: indexPath, animated: animated) } + /// Scrolls the pager view contents until the specified item is visible. + /// + /// - Parameters: + /// - index: The index of the item to scroll into view. + /// - animated: Specify true to animate the scrolling behavior or false to adjust the pager view’s visible content immediately. @objc(scrollToItemAtIndex:animated:) open func scrollToItem(at index: Int, animated: Bool) { guard index < self.numberOfItems else { diff --git a/FSPagerView/FSPagerViewCell.swift b/FSPagerView/FSPagerViewCell.swift index ec0840a..93168b1 100644 --- a/FSPagerView/FSPagerViewCell.swift +++ b/FSPagerView/FSPagerViewCell.swift @@ -9,11 +9,8 @@ import UIKit open class FSPagerViewCell: UICollectionViewCell { - - fileprivate let kvoContext = UnsafeMutableRawPointer(bitPattern: 0) - fileprivate let selectionColor = UIColor(white: 0.2, alpha: 0.2) - internal weak var _textLabel: UILabel? + /// Returns the label used for the main textual content of the pager view cell. open var textLabel: UILabel? { if let _ = _textLabel { return _textLabel @@ -33,8 +30,8 @@ open class FSPagerViewCell: UICollectionViewCell { _textLabel = textLabel return textLabel } - - internal weak var _imageView: UIImageView? + + /// Returns the image view of the pager view cell. Default is nil. open var imageView: UIImageView? { if let _ = _imageView { return _imageView @@ -45,6 +42,12 @@ open class FSPagerViewCell: UICollectionViewCell { return imageView } + internal weak var _textLabel: UILabel? + internal weak var _imageView: UIImageView? + + fileprivate let kvoContext = UnsafeMutableRawPointer(bitPattern: 0) + fileprivate let selectionColor = UIColor(white: 0.2, alpha: 0.2) + fileprivate weak var _selectedForegroundView: UIView? fileprivate var selectedForegroundView: UIView? { if let _ = _selectedForegroundView { diff --git a/README-OBJECTIVE-C.md b/README-OBJECTIVE-C.md index 86ea4e3..3bace5d 100644 --- a/README-OBJECTIVE-C.md +++ b/README-OBJECTIVE-C.md @@ -1,6 +1,9 @@ # FSPagerView -| [SWIFT](https://github.com/WenchaoD/FSPagerView/blob/master/README.md) | OBJECTIVE-C | +[![Platform](https://img.shields.io/badge/platform-iOS%207-blue.svg?style=flat)](http://cocoadocs.org/docsets/FSPagerView) + + +| [SWIFT](https://github.com/WenchaoD/FSPagerView/blob/master/README.md) | OBJECTIVE-C | |---|---| **FSPagerView** is an elegant Screen Slide Library implemented primarily with ***UICollectionView***. It is extremely helpful for making Banner、Product Show、Welcome/Guide Pages、Screen/ViewController Sliders. diff --git a/README.md b/README.md index 8e88a10..e52add8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # FSPagerView -| SWIFT | [OBJECTIVE-C](https://github.com/WenchaoD/FSPagerView/blob/master/README-OBJECTIVE-C.md) | +[![Platform](https://img.shields.io/badge/platform-iOS%207-blue.svg?style=flat)](http://cocoadocs.org/docsets/FSPagerView) + +| SWIFT | [OBJECTIVE-C](https://github.com/WenchaoD/FSPagerView/blob/master/README-OBJECTIVE-C.md) | |---|---| **FSPagerView** is an elegant Screen Slide Library implemented primarily with ***UICollectionView***. It is extremely helpful for making Banner、Product Show、Welcome/Guide Pages、Screen/ViewController Sliders.