Repository: WenchaoD/FSPagerView
Branch: master
Commit: f90ab7d2ee68
Files: 53
Total size: 312.3 KB
Directory structure:
gitextract_gieyc_z4/
├── .gitignore
├── .swiftpm/
│ └── xcode/
│ └── package.xcworkspace/
│ └── contents.xcworkspacedata
├── FSPageViewExample-Swift/
│ ├── FSPagerViewExample/
│ │ ├── AppDelegate.swift
│ │ ├── Base.lproj/
│ │ │ ├── LaunchScreen.storyboard
│ │ │ └── Main.storyboard
│ │ ├── BasicExampleViewController.swift
│ │ ├── Info.plist
│ │ ├── PageControlExampleViewController.swift
│ │ └── TransformerExampleViewController.swift
│ ├── FSPagerViewExample.xcodeproj/
│ │ ├── project.pbxproj
│ │ └── project.xcworkspace/
│ │ └── contents.xcworkspacedata
│ └── FSPagerViewExampleUITests/
│ ├── FSPagerViewExampleUITests.swift
│ └── Info.plist
├── FSPagerView/
│ ├── FSPagerView/
│ │ ├── FSPagerView.h
│ │ └── Info.plist
│ └── FSPagerView.xcodeproj/
│ ├── project.pbxproj
│ ├── project.xcworkspace/
│ │ └── contents.xcworkspacedata
│ └── xcshareddata/
│ └── xcschemes/
│ └── FSPagerView.xcscheme
├── FSPagerView.podspec
├── FSPagerViewExample-Objc/
│ ├── FSPagerViewExample-Objc/
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── Base.lproj/
│ │ │ ├── LaunchScreen.storyboard
│ │ │ └── Main.storyboard
│ │ ├── BasicExampleViewController.h
│ │ ├── BasicExampleViewController.m
│ │ ├── Info.plist
│ │ ├── PageControlExampleViewController.h
│ │ ├── PageControlExampleViewController.m
│ │ ├── TransformerExampleViewController.h
│ │ ├── TransformerExampleViewController.m
│ │ └── main.m
│ ├── FSPagerViewExample-Objc.xcodeproj/
│ │ ├── project.pbxproj
│ │ └── project.xcworkspace/
│ │ └── contents.xcworkspacedata
│ └── FSPagerViewExample-ObjcUITests/
│ ├── FSPagerViewExample_ObjcUITests.swift
│ └── Info.plist
├── FSPagerViewExamples.xcworkspace/
│ └── contents.xcworkspacedata
├── LICENSE
├── Package.swift
├── README-OBJECTIVE-C.md
├── README.md
├── Resources/
│ └── Assets.xcassets/
│ ├── AppIcon.appiconset/
│ │ └── Contents.json
│ ├── Contents.json
│ ├── icon_cat.imageset/
│ │ └── Contents.json
│ └── icon_footprint.imageset/
│ └── Contents.json
└── Sources/
├── FSPageControl.swift
├── FSPageViewLayout.swift
├── FSPageViewTransformer.swift
├── FSPagerCollectionView.swift
├── FSPagerView.swift
├── FSPagerViewCell.swift
├── FSPagerViewLayoutAttributes.swift
├── FSPagerViewObjcCompat.h
└── FSPagerViewObjcCompat.m
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## Build generated
build/
DerivedData/
## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/
## Other
*.moved-aside
*.xccheckout
*.xcscmblueprint
*.xcuserstate
## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM
## Playgrounds
timeline.xctimeline
playground.xcworkspace
# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
# Package.pins
.build/
# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/
# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts
Carthage/Build
# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
Index/*
================================================
FILE: .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
================================================
================================================
FILE: FSPageViewExample-Swift/FSPagerViewExample/AppDelegate.swift
================================================
//
// AppDelegate.swift
// FSPagerViewExample
//
// Created by Wenchao Ding on 06/01/2017.
// Copyright © 2017 Wenchao Ding. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
================================================
FILE: FSPageViewExample-Swift/FSPagerViewExample/Base.lproj/LaunchScreen.storyboard
================================================
================================================
FILE: FSPageViewExample-Swift/FSPagerViewExample/Base.lproj/Main.storyboard
================================================
================================================
FILE: FSPageViewExample-Swift/FSPagerViewExample/BasicExampleViewController.swift
================================================
//
// ViewController.swift
// FSPagerViewExample
//
// Created by Wenchao Ding on 17/12/2016.
// Copyright © 2016 Wenchao Ding. All rights reserved.
//
import UIKit
class BasicExampleViewController: UIViewController,UITableViewDataSource,UITableViewDelegate,FSPagerViewDataSource,FSPagerViewDelegate {
fileprivate let sectionTitles = ["Configurations", "Decelaration Distance", "Item Size", "Interitem Spacing", "Number Of Items"]
fileprivate let configurationTitles = ["Automatic sliding","Infinite"]
fileprivate let decelerationDistanceOptions = ["Automatic", "1", "2"]
fileprivate let imageNames = ["1.jpg","2.jpg","3.jpg","4.jpg","5.jpg","6.jpg","7.jpg"]
fileprivate var numberOfItems = 7
@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var pagerView: FSPagerView! {
didSet {
self.pagerView.register(FSPagerViewCell.self, forCellWithReuseIdentifier: "cell")
self.pagerView.itemSize = FSPagerView.automaticSize
}
}
@IBOutlet weak var pageControl: FSPageControl! {
didSet {
self.pageControl.numberOfPages = self.imageNames.count
self.pageControl.contentHorizontalAlignment = .right
self.pageControl.contentInsets = UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 20)
}
}
// MARK:- UITableViewDataSource
func numberOfSections(in tableView: UITableView) -> Int {
return self.sectionTitles.count
}
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
switch section {
case 0:
return self.configurationTitles.count
case 1:
return self.decelerationDistanceOptions.count
case 2,3,4:
return 1
default:
return 0
}
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
switch indexPath.section {
case 0:
// Configurations
let cell = tableView.dequeueReusableCell(withIdentifier: "cell")!
cell.textLabel?.text = self.configurationTitles[indexPath.row]
if indexPath.row == 0 {
// Automatic Sliding
cell.accessoryType = self.pagerView.automaticSlidingInterval > 0 ? .checkmark : .none
} else if indexPath.row == 1 {
// IsInfinite
cell.accessoryType = self.pagerView.isInfinite ? .checkmark : .none
}
return cell
case 1:
// Decelaration Distance
let cell = tableView.dequeueReusableCell(withIdentifier: "cell")!
cell.textLabel?.text = self.decelerationDistanceOptions[indexPath.row]
switch indexPath.row {
case 0:
cell.accessoryType = self.pagerView.decelerationDistance == FSPagerView.automaticDistance ? .checkmark : .none
case 1:
cell.accessoryType = self.pagerView.decelerationDistance == 1 ? .checkmark : .none
case 2:
cell.accessoryType = self.pagerView.decelerationDistance == 2 ? .checkmark : .none
default:
break;
}
return cell;
case 2:
// Item Spacing
let cell = tableView.dequeueReusableCell(withIdentifier: "slider_cell")!
let slider = cell.contentView.subviews.first as! UISlider
slider.tag = 1
slider.value = {
let scale: CGFloat = self.pagerView.itemSize.width/self.pagerView.frame.width
let value: CGFloat = (0.5-scale)*2
return Float(value)
}()
slider.isContinuous = true
return cell
case 3:
// Interitem Spacing
let cell = tableView.dequeueReusableCell(withIdentifier: "slider_cell")!
let slider = cell.contentView.subviews.first as! UISlider
slider.tag = 2
slider.value = Float(self.pagerView.interitemSpacing/20.0)
slider.isContinuous = true
return cell
case 4:
// Number Of Items
let cell = tableView.dequeueReusableCell(withIdentifier: "slider_cell")!
let slider = cell.contentView.subviews.first as! UISlider
slider.tag = 3
slider.minimumValue = 1.0 / 7
slider.maximumValue = 1.0
slider.value = Float(self.numberOfItems) / 7.0
slider.isContinuous = false
return cell
default:
break
}
return tableView.dequeueReusableCell(withIdentifier: "cell")!
}
// MARK:- UITableViewDelegate
func tableView(_ tableView: UITableView, shouldHighlightRowAt indexPath: IndexPath) -> Bool {
return indexPath.section == 0 || indexPath.section == 1
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
switch indexPath.section {
case 0:
if indexPath.row == 0 { // Automatic Sliding
self.pagerView.automaticSlidingInterval = 3.0 - self.pagerView.automaticSlidingInterval
} else if indexPath.row == 1 { // IsInfinite
self.pagerView.isInfinite = !self.pagerView.isInfinite
}
tableView.reloadSections([indexPath.section], with: .automatic)
case 1:
switch indexPath.row {
case 0:
self.pagerView.decelerationDistance = FSPagerView.automaticDistance
case 1:
self.pagerView.decelerationDistance = 1
case 2:
self.pagerView.decelerationDistance = 2
default:
break
}
tableView.reloadSections([indexPath.section], with: .automatic)
default:
break
}
}
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return self.sectionTitles[section]
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return section == 0 ? 40 : 20
}
// MARK:- FSPagerView DataSource
public func numberOfItems(in pagerView: FSPagerView) -> Int {
return self.numberOfItems
}
public func pagerView(_ pagerView: FSPagerView, cellForItemAt index: Int) -> FSPagerViewCell {
let cell = pagerView.dequeueReusableCell(withReuseIdentifier: "cell", at: index)
cell.imageView?.image = UIImage(named: self.imageNames[index])
cell.imageView?.contentMode = .scaleAspectFill
cell.imageView?.clipsToBounds = true
cell.textLabel?.text = index.description+index.description
return cell
}
// MARK:- FSPagerView Delegate
func pagerView(_ pagerView: FSPagerView, didSelectItemAt index: Int) {
pagerView.deselectItem(at: index, animated: true)
pagerView.scrollToItem(at: index, animated: true)
}
func pagerViewWillEndDragging(_ pagerView: FSPagerView, targetIndex: Int) {
self.pageControl.currentPage = targetIndex
}
func pagerViewDidEndScrollAnimation(_ pagerView: FSPagerView) {
self.pageControl.currentPage = pagerView.currentIndex
}
@IBAction func sliderValueChanged(_ sender: UISlider) {
switch sender.tag {
case 1:
let newScale = 0.5+CGFloat(sender.value)*0.5 // [0.5 - 1.0]
self.pagerView.itemSize = self.pagerView.frame.size.applying(CGAffineTransform(scaleX: newScale, y: newScale))
case 2:
self.pagerView.interitemSpacing = CGFloat(sender.value) * 20 // [0 - 20]
case 3:
self.numberOfItems = Int(roundf(sender.value*7.0))
self.pageControl.numberOfPages = self.numberOfItems
self.pagerView.reloadData()
default:
break
}
}
}
================================================
FILE: FSPageViewExample-Swift/FSPagerViewExample/Info.plist
================================================
CFBundleDevelopmentRegion
en
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIdentifier
$(PRODUCT_BUNDLE_IDENTIFIER)
CFBundleInfoDictionaryVersion
6.0
CFBundleName
$(PRODUCT_NAME)
CFBundlePackageType
APPL
CFBundleShortVersionString
1.0
CFBundleVersion
1
LSRequiresIPhoneOS
UILaunchStoryboardName
LaunchScreen
UIMainStoryboardFile
Main
UIRequiredDeviceCapabilities
armv7
UISupportedInterfaceOrientations
UIInterfaceOrientationPortrait
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
UISupportedInterfaceOrientations~ipad
UIInterfaceOrientationPortrait
UIInterfaceOrientationPortraitUpsideDown
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
================================================
FILE: FSPageViewExample-Swift/FSPagerViewExample/PageControlExampleViewController.swift
================================================
//
// PageControlExampleViewController.swift
// FSPagerViewExample
//
// Created by Wenchao Ding on 17/01/2017.
// Copyright © 2017 Wenchao Ding. All rights reserved.
//
import UIKit
class PageControlExampleViewController: UIViewController,UITableViewDataSource,UITableViewDelegate,FSPagerViewDataSource,FSPagerViewDelegate {
fileprivate let imageNames = ["1.jpg","2.jpg","3.jpg","4.jpg","5.jpg","6.jpg","7.jpg"]
fileprivate let pageControlStyles = ["Default", "Ring", "UIImage", "UIBezierPath - Star", "UIBezierPath - Heart"]
fileprivate let pageControlAlignments = ["Right", "Center", "Left"]
fileprivate let sectionTitles = ["Style", "Item Spacing", "Interitem Spacing", "Horizontal Alignment"]
fileprivate var styleIndex = 0 {
didSet {
// Clean up
self.pageControl.setStrokeColor(nil, for: .normal)
self.pageControl.setStrokeColor(nil, for: .selected)
self.pageControl.setFillColor(nil, for: .normal)
self.pageControl.setFillColor(nil, for: .selected)
self.pageControl.setImage(nil, for: .normal)
self.pageControl.setImage(nil, for: .selected)
self.pageControl.setPath(nil, for: .normal)
self.pageControl.setPath(nil, for: .selected)
switch self.styleIndex {
case 0:
// Default
break
case 1:
// Ring
self.pageControl.setStrokeColor(.green, for: .normal)
self.pageControl.setStrokeColor(.green, for: .selected)
self.pageControl.setFillColor(.green, for: .selected)
case 2:
// Image
self.pageControl.setImage(UIImage(named:"icon_footprint"), for: .normal)
self.pageControl.setImage(UIImage(named:"icon_cat"), for: .selected)
case 3:
// UIBezierPath - Star
self.pageControl.setStrokeColor(.yellow, for: .normal)
self.pageControl.setStrokeColor(.yellow, for: .selected)
self.pageControl.setFillColor(.yellow, for: .selected)
self.pageControl.setPath(self.starPath, for: .normal)
self.pageControl.setPath(self.starPath, for: .selected)
case 4:
// UIBezierPath - Heart
let color = UIColor(red: 255/255.0, green: 102/255.0, blue: 255/255.0, alpha: 1.0)
self.pageControl.setStrokeColor(color, for: .normal)
self.pageControl.setStrokeColor(color, for: .selected)
self.pageControl.setFillColor(color, for: .selected)
self.pageControl.setPath(self.heartPath, for: .normal)
self.pageControl.setPath(self.heartPath, for: .selected)
default:
break
}
}
}
fileprivate var alignmentIndex = 0 {
didSet {
self.pageControl.contentHorizontalAlignment = [.right,.center,.left][self.alignmentIndex]
}
}
// ⭐️
fileprivate var starPath: UIBezierPath {
let width = self.pageControl.itemSpacing
let height = self.pageControl.itemSpacing
let starPath = UIBezierPath()
starPath.move(to: CGPoint(x: width*0.5, y: 0))
starPath.addLine(to: CGPoint(x: width*0.677, y: height*0.257))
starPath.addLine(to: CGPoint(x: width*0.975, y: height*0.345))
starPath.addLine(to: CGPoint(x: width*0.785, y: height*0.593))
starPath.addLine(to: CGPoint(x: width*0.794, y: height*0.905))
starPath.addLine(to: CGPoint(x: width*0.5, y: height*0.8))
starPath.addLine(to: CGPoint(x: width*0.206, y: height*0.905))
starPath.addLine(to: CGPoint(x: width*0.215, y: height*0.593))
starPath.addLine(to: CGPoint(x: width*0.025, y: height*0.345))
starPath.addLine(to: CGPoint(x: width*0.323, y: height*0.257))
starPath.close()
return starPath
}
// ❤️
fileprivate var heartPath: UIBezierPath {
let width = self.pageControl.itemSpacing
let height = self.pageControl.itemSpacing
let heartPath = UIBezierPath()
heartPath.move(to: CGPoint(x: width*0.5, y: height))
heartPath.addCurve(
to: CGPoint(x: 0, y: height*0.25),
controlPoint1: CGPoint(x: width*0.5, y: height*0.75) ,
controlPoint2: CGPoint(x: 0, y: height*0.5)
)
heartPath.addArc(
withCenter: CGPoint(x: width*0.25,y: height*0.25),
radius: width * 0.25,
startAngle: .pi,
endAngle: 0,
clockwise: true
)
heartPath.addArc(
withCenter: CGPoint(x: width*0.75, y: height*0.25),
radius: width * 0.25,
startAngle: .pi,
endAngle: 0,
clockwise: true
)
heartPath.addCurve(
to: CGPoint(x: width*0.5, y: height),
controlPoint1: CGPoint(x: width, y: height*0.5),
controlPoint2: CGPoint(x: width*0.5, y: height*0.75)
)
heartPath.close()
return heartPath
}
@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var pagerView: FSPagerView! {
didSet {
self.pagerView.register(FSPagerViewCell.self, forCellWithReuseIdentifier: "cell")
}
}
@IBOutlet weak var pageControl: FSPageControl! {
didSet {
self.pageControl.numberOfPages = self.imageNames.count
self.pageControl.contentHorizontalAlignment = .right
self.pageControl.contentInsets = UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 20)
self.pageControl.hidesForSinglePage = true
}
}
// MARK:- UITableViewDataSource
func numberOfSections(in tableView: UITableView) -> Int {
return self.sectionTitles.count
}
@available(iOS 2.0, *)
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
switch section {
case 0:
return self.pageControlStyles.count
case 1,2:
return 1
case 3:
return self.pageControlAlignments.count
default:
break
}
return 0
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
switch indexPath.section {
case 0:
let cell = tableView.dequeueReusableCell(withIdentifier: "cell")!
cell.textLabel?.text = self.pageControlStyles[indexPath.row]
cell.accessoryType = self.styleIndex==indexPath.row ? .checkmark : .none
return cell
case 1:
let cell = tableView.dequeueReusableCell(withIdentifier: "slider_cell")!
let slider = cell.contentView.subviews.first as! UISlider
slider.tag = indexPath.section
slider.value = Float((self.pageControl.itemSpacing-6.0)/10.0)
return cell
case 2:
let cell = tableView.dequeueReusableCell(withIdentifier: "slider_cell")!
let slider = cell.contentView.subviews.first as! UISlider
slider.tag = indexPath.section
slider.value = Float((self.pageControl.interitemSpacing-6.0)/10.0)
return cell
case 3:
let cell = tableView.dequeueReusableCell(withIdentifier: "cell")!
cell.textLabel?.text = self.pageControlAlignments[indexPath.row]
cell.accessoryType = self.alignmentIndex==indexPath.row ? .checkmark : .none
return cell
default:
break
}
return tableView.dequeueReusableCell(withIdentifier: "cell")!
}
// MARK:- UITableViewDelegate
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return self.sectionTitles[section]
}
func tableView(_ tableView: UITableView, shouldHighlightRowAt indexPath: IndexPath) -> Bool {
return [0,3].contains(indexPath.section) // 0 or 3
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
switch indexPath.section {
case 0:
self.styleIndex = indexPath.row
tableView.reloadSections([indexPath.section], with: .automatic)
case 3:
self.alignmentIndex = indexPath.row
tableView.reloadSections([indexPath.section], with: .automatic)
default:
break
}
}
// MARK:- FSPagerViewDataSource
func numberOfItems(in pagerView: FSPagerView) -> Int {
return self.imageNames.count
}
public func pagerView(_ pagerView: FSPagerView, cellForItemAt index: Int) -> FSPagerViewCell {
let cell = pagerView.dequeueReusableCell(withReuseIdentifier: "cell", at: index)
cell.imageView?.image = UIImage(named: self.imageNames[index])
cell.imageView?.contentMode = .scaleAspectFill
return cell
}
func pagerView(_ pagerView: FSPagerView, didSelectItemAt index: Int) {
pagerView.deselectItem(at: index, animated: true)
}
// MARK:- FSPagerViewDelegate
func pagerViewWillEndDragging(_ pagerView: FSPagerView, targetIndex: Int) {
self.pageControl.currentPage = targetIndex
}
// MARK:- Target Actions
@IBAction func sliderValueChanged(_ sender: UISlider) {
switch sender.tag {
case 1:
self.pageControl.itemSpacing = 6.0 + CGFloat(sender.value*10.0) // [6 - 16]
// Redraw UIBezierPath
if [3,4].contains(self.styleIndex) {
let index = self.styleIndex
self.styleIndex = index
}
case 2:
self.pageControl.interitemSpacing = 6.0 + CGFloat(sender.value*10.0) // [6 - 16]
default:
break
}
}
}
================================================
FILE: FSPageViewExample-Swift/FSPagerViewExample/TransformerExampleViewController.swift
================================================
//
// TransformerExampleViewController.swift
// FSPagerViewExample
//
// Created by Wenchao Ding on 09/01/2017.
// Copyright © 2017 Wenchao Ding. All rights reserved.
//
import UIKit
class TransformerExampleViewController: UIViewController,FSPagerViewDataSource,FSPagerViewDelegate, UITableViewDataSource,UITableViewDelegate {
fileprivate let imageNames = ["1.jpg","2.jpg","3.jpg","4.jpg","5.jpg","6.jpg","7.jpg"]
fileprivate let transformerNames = ["cross fading", "zoom out", "depth", "linear", "overlap", "ferris wheel", "inverted ferris wheel", "coverflow", "cubic"]
fileprivate let transformerTypes: [FSPagerViewTransformerType] = [.crossFading,
.zoomOut,
.depth,
.linear,
.overlap,
.ferrisWheel,
.invertedFerrisWheel,
.coverFlow,
.cubic]
fileprivate var typeIndex = 0 {
didSet {
let type = self.transformerTypes[typeIndex]
self.pagerView.transformer = FSPagerViewTransformer(type:type)
switch type {
case .crossFading, .zoomOut, .depth:
self.pagerView.itemSize = FSPagerView.automaticSize
self.pagerView.decelerationDistance = 1
case .linear, .overlap:
let transform = CGAffineTransform(scaleX: 0.6, y: 0.75)
self.pagerView.itemSize = self.pagerView.frame.size.applying(transform)
self.pagerView.decelerationDistance = FSPagerView.automaticDistance
case .ferrisWheel, .invertedFerrisWheel:
self.pagerView.itemSize = CGSize(width: 180, height: 140)
self.pagerView.decelerationDistance = FSPagerView.automaticDistance
case .coverFlow:
self.pagerView.itemSize = CGSize(width: 220, height: 170)
self.pagerView.decelerationDistance = FSPagerView.automaticDistance
case .cubic:
let transform = CGAffineTransform(scaleX: 0.9, y: 0.9)
self.pagerView.itemSize = self.pagerView.frame.size.applying(transform)
self.pagerView.decelerationDistance = 1
}
}
}
@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var pagerView: FSPagerView! {
didSet {
self.pagerView.register(FSPagerViewCell.self, forCellWithReuseIdentifier: "cell")
self.typeIndex = 0
}
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
let index = self.typeIndex
self.typeIndex = index // Manually trigger didSet
}
// MARK:- UITableViewDataSource
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
@available(iOS 2.0, *)
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.transformerNames.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell")!
cell.textLabel?.text = self.transformerNames[indexPath.row]
cell.accessoryType = indexPath.row == self.typeIndex ? .checkmark : .none
return cell
}
// MARK:- UITableViewDelegate
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
self.typeIndex = indexPath.row
if let visibleRows = tableView.indexPathsForVisibleRows {
tableView.reloadRows(at: visibleRows, with: .automatic)
}
}
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return "Transformers"
}
// MARK:- FSPagerViewDataSource
public func numberOfItems(in pagerView: FSPagerView) -> Int {
return imageNames.count
}
public func pagerView(_ pagerView: FSPagerView, cellForItemAt index: Int) -> FSPagerViewCell {
let cell = pagerView.dequeueReusableCell(withReuseIdentifier: "cell", at: index)
cell.imageView?.image = UIImage(named: self.imageNames[index])
cell.imageView?.contentMode = .scaleAspectFill
cell.imageView?.clipsToBounds = true
return cell
}
func pagerView(_ pagerView: FSPagerView, didSelectItemAt index: Int) {
pagerView.deselectItem(at: index, animated: true)
pagerView.scrollToItem(at: index, animated: true)
}
}
================================================
FILE: FSPageViewExample-Swift/FSPagerViewExample.xcodeproj/project.pbxproj
================================================
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
F931E00C2158A1F3001B2A01 /* FSPagerViewObjcCompat.m in Sources */ = {isa = PBXBuildFile; fileRef = F931E00B2158A1F3001B2A01 /* FSPagerViewObjcCompat.m */; };
F954839A1E625F1E0069FD7E /* FSPagerViewLayoutAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = F95483991E625F1E0069FD7E /* FSPagerViewLayoutAttributes.swift */; };
F954839B1E625F1E0069FD7E /* FSPagerViewLayoutAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = F95483991E625F1E0069FD7E /* FSPagerViewLayoutAttributes.swift */; };
F9580B571E5D995400C5B267 /* FSPageControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9580B511E5D995400C5B267 /* FSPageControl.swift */; };
F9580B581E5D995400C5B267 /* FSPagerCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9580B521E5D995400C5B267 /* FSPagerCollectionView.swift */; };
F9580B591E5D995400C5B267 /* FSPagerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9580B531E5D995400C5B267 /* FSPagerView.swift */; };
F9580B5A1E5D995400C5B267 /* FSPagerViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9580B541E5D995400C5B267 /* FSPagerViewCell.swift */; };
F9580B5B1E5D995400C5B267 /* FSPageViewLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9580B551E5D995400C5B267 /* FSPageViewLayout.swift */; };
F9580B5C1E5D995400C5B267 /* FSPageViewTransformer.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9580B561E5D995400C5B267 /* FSPageViewTransformer.swift */; };
F9C6942F1E40C583007084B6 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9C694241E40C583007084B6 /* AppDelegate.swift */; };
F9C694311E40C583007084B6 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F9C694261E40C583007084B6 /* LaunchScreen.storyboard */; };
F9C694321E40C583007084B6 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F9C694281E40C583007084B6 /* Main.storyboard */; };
F9C694331E40C583007084B6 /* BasicExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9C6942A1E40C583007084B6 /* BasicExampleViewController.swift */; };
F9C694351E40C583007084B6 /* PageControlExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9C6942C1E40C583007084B6 /* PageControlExampleViewController.swift */; };
F9C694361E40C583007084B6 /* TransformerExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9C6942E1E40C583007084B6 /* TransformerExampleViewController.swift */; };
F9C6945A1E40C720007084B6 /* FSPagerViewExampleUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9C694591E40C720007084B6 /* FSPagerViewExampleUITests.swift */; };
F9C694711E40C8DA007084B6 /* 1.jpg in Resources */ = {isa = PBXBuildFile; fileRef = F9C694621E40C8DA007084B6 /* 1.jpg */; };
F9C694791E40C8DA007084B6 /* 2.jpg in Resources */ = {isa = PBXBuildFile; fileRef = F9C6946A1E40C8DA007084B6 /* 2.jpg */; };
F9C6947A1E40C8DA007084B6 /* 3.jpg in Resources */ = {isa = PBXBuildFile; fileRef = F9C6946B1E40C8DA007084B6 /* 3.jpg */; };
F9C6947B1E40C8DA007084B6 /* 4.jpg in Resources */ = {isa = PBXBuildFile; fileRef = F9C6946C1E40C8DA007084B6 /* 4.jpg */; };
F9C6947C1E40C8DA007084B6 /* 5.jpg in Resources */ = {isa = PBXBuildFile; fileRef = F9C6946D1E40C8DA007084B6 /* 5.jpg */; };
F9C6947D1E40C8DA007084B6 /* 6.jpg in Resources */ = {isa = PBXBuildFile; fileRef = F9C6946E1E40C8DA007084B6 /* 6.jpg */; };
F9C6947E1E40C8DA007084B6 /* 7.jpg in Resources */ = {isa = PBXBuildFile; fileRef = F9C6946F1E40C8DA007084B6 /* 7.jpg */; };
F9DF961F1E7F5B360010506C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F9DF961E1E7F5B360010506C /* Assets.xcassets */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
F9C6945C1E40C720007084B6 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = F97C966F1E1FDE25002D9E7E /* Project object */;
proxyType = 1;
remoteGlobalIDString = F97C96761E1FDE25002D9E7E;
remoteInfo = FSPagerViewExample;
};
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
50989DFE2151DB29004DBB4A /* FSPagerViewObjcCompat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FSPagerViewObjcCompat.h; sourceTree = ""; };
F931E00B2158A1F3001B2A01 /* FSPagerViewObjcCompat.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FSPagerViewObjcCompat.m; sourceTree = ""; };
F95483991E625F1E0069FD7E /* FSPagerViewLayoutAttributes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FSPagerViewLayoutAttributes.swift; sourceTree = ""; };
F9580B511E5D995400C5B267 /* FSPageControl.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FSPageControl.swift; sourceTree = ""; };
F9580B521E5D995400C5B267 /* FSPagerCollectionView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FSPagerCollectionView.swift; sourceTree = ""; };
F9580B531E5D995400C5B267 /* FSPagerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FSPagerView.swift; sourceTree = ""; };
F9580B541E5D995400C5B267 /* FSPagerViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FSPagerViewCell.swift; sourceTree = ""; };
F9580B551E5D995400C5B267 /* FSPageViewLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FSPageViewLayout.swift; sourceTree = ""; };
F9580B561E5D995400C5B267 /* FSPageViewTransformer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FSPageViewTransformer.swift; sourceTree = ""; };
F97C96771E1FDE25002D9E7E /* FSPagerViewExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FSPagerViewExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
F9C694241E40C583007084B6 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
F9C694271E40C583007084B6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
F9C694291E40C583007084B6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
F9C6942A1E40C583007084B6 /* BasicExampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BasicExampleViewController.swift; sourceTree = ""; };
F9C6942B1E40C583007084B6 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
F9C6942C1E40C583007084B6 /* PageControlExampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PageControlExampleViewController.swift; sourceTree = ""; };
F9C6942E1E40C583007084B6 /* TransformerExampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TransformerExampleViewController.swift; sourceTree = ""; };
F9C694571E40C720007084B6 /* FSPagerViewExampleUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = FSPagerViewExampleUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
F9C694591E40C720007084B6 /* FSPagerViewExampleUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FSPagerViewExampleUITests.swift; sourceTree = ""; };
F9C6945B1E40C720007084B6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
F9C694621E40C8DA007084B6 /* 1.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 1.jpg; sourceTree = ""; };
F9C6946A1E40C8DA007084B6 /* 2.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 2.jpg; sourceTree = ""; };
F9C6946B1E40C8DA007084B6 /* 3.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 3.jpg; sourceTree = ""; };
F9C6946C1E40C8DA007084B6 /* 4.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 4.jpg; sourceTree = ""; };
F9C6946D1E40C8DA007084B6 /* 5.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 5.jpg; sourceTree = ""; };
F9C6946E1E40C8DA007084B6 /* 6.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 6.jpg; sourceTree = ""; };
F9C6946F1E40C8DA007084B6 /* 7.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 7.jpg; sourceTree = ""; };
F9DF961E1E7F5B360010506C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
F97C96741E1FDE25002D9E7E /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
F9C694541E40C720007084B6 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
F9580B501E5D995400C5B267 /* Sources */ = {
isa = PBXGroup;
children = (
F9580B511E5D995400C5B267 /* FSPageControl.swift */,
F9580B521E5D995400C5B267 /* FSPagerCollectionView.swift */,
F9580B531E5D995400C5B267 /* FSPagerView.swift */,
F9580B541E5D995400C5B267 /* FSPagerViewCell.swift */,
F9580B551E5D995400C5B267 /* FSPageViewLayout.swift */,
F9580B561E5D995400C5B267 /* FSPageViewTransformer.swift */,
F95483991E625F1E0069FD7E /* FSPagerViewLayoutAttributes.swift */,
50989DFE2151DB29004DBB4A /* FSPagerViewObjcCompat.h */,
F931E00B2158A1F3001B2A01 /* FSPagerViewObjcCompat.m */,
);
name = Sources;
path = ../Sources;
sourceTree = "";
};
F97C966E1E1FDE25002D9E7E = {
isa = PBXGroup;
children = (
F9580B501E5D995400C5B267 /* Sources */,
F9C694231E40C583007084B6 /* FSPagerViewExample */,
F9C694581E40C720007084B6 /* FSPagerViewExampleUITests */,
F97C96781E1FDE25002D9E7E /* Products */,
);
sourceTree = "";
};
F97C96781E1FDE25002D9E7E /* Products */ = {
isa = PBXGroup;
children = (
F97C96771E1FDE25002D9E7E /* FSPagerViewExample.app */,
F9C694571E40C720007084B6 /* FSPagerViewExampleUITests.xctest */,
);
name = Products;
sourceTree = "";
};
F9C694231E40C583007084B6 /* FSPagerViewExample */ = {
isa = PBXGroup;
children = (
F9C694241E40C583007084B6 /* AppDelegate.swift */,
F9C6942A1E40C583007084B6 /* BasicExampleViewController.swift */,
F9C6942E1E40C583007084B6 /* TransformerExampleViewController.swift */,
F9C6942C1E40C583007084B6 /* PageControlExampleViewController.swift */,
F9C694261E40C583007084B6 /* LaunchScreen.storyboard */,
F9C694281E40C583007084B6 /* Main.storyboard */,
F9C694611E40C8DA007084B6 /* Resources */,
F9C694371E40C59E007084B6 /* Supporting Files */,
);
path = FSPagerViewExample;
sourceTree = "";
};
F9C694371E40C59E007084B6 /* Supporting Files */ = {
isa = PBXGroup;
children = (
F9C6942B1E40C583007084B6 /* Info.plist */,
);
name = "Supporting Files";
sourceTree = "";
};
F9C694581E40C720007084B6 /* FSPagerViewExampleUITests */ = {
isa = PBXGroup;
children = (
F9C694591E40C720007084B6 /* FSPagerViewExampleUITests.swift */,
F9C6945B1E40C720007084B6 /* Info.plist */,
);
path = FSPagerViewExampleUITests;
sourceTree = "";
};
F9C694611E40C8DA007084B6 /* Resources */ = {
isa = PBXGroup;
children = (
F9DF961E1E7F5B360010506C /* Assets.xcassets */,
F9C694621E40C8DA007084B6 /* 1.jpg */,
F9C6946A1E40C8DA007084B6 /* 2.jpg */,
F9C6946B1E40C8DA007084B6 /* 3.jpg */,
F9C6946C1E40C8DA007084B6 /* 4.jpg */,
F9C6946D1E40C8DA007084B6 /* 5.jpg */,
F9C6946E1E40C8DA007084B6 /* 6.jpg */,
F9C6946F1E40C8DA007084B6 /* 7.jpg */,
);
name = Resources;
path = ../../Resources;
sourceTree = "";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
F97C96761E1FDE25002D9E7E /* FSPagerViewExample */ = {
isa = PBXNativeTarget;
buildConfigurationList = F97C969F1E1FDE25002D9E7E /* Build configuration list for PBXNativeTarget "FSPagerViewExample" */;
buildPhases = (
F97C96731E1FDE25002D9E7E /* Sources */,
F97C96741E1FDE25002D9E7E /* Frameworks */,
F97C96751E1FDE25002D9E7E /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = FSPagerViewExample;
productName = FSPageSliderExample;
productReference = F97C96771E1FDE25002D9E7E /* FSPagerViewExample.app */;
productType = "com.apple.product-type.application";
};
F9C694561E40C720007084B6 /* FSPagerViewExampleUITests */ = {
isa = PBXNativeTarget;
buildConfigurationList = F9C6945E1E40C720007084B6 /* Build configuration list for PBXNativeTarget "FSPagerViewExampleUITests" */;
buildPhases = (
F9C694531E40C720007084B6 /* Sources */,
F9C694541E40C720007084B6 /* Frameworks */,
F9C694551E40C720007084B6 /* Resources */,
);
buildRules = (
);
dependencies = (
F9C6945D1E40C720007084B6 /* PBXTargetDependency */,
);
name = FSPagerViewExampleUITests;
productName = FSPagerViewExampleUITests;
productReference = F9C694571E40C720007084B6 /* FSPagerViewExampleUITests.xctest */;
productType = "com.apple.product-type.bundle.ui-testing";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
F97C966F1E1FDE25002D9E7E /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0820;
LastUpgradeCheck = 1030;
ORGANIZATIONNAME = "Wenchao Ding";
TargetAttributes = {
F97C96761E1FDE25002D9E7E = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = HZF422TY46;
LastSwiftMigration = 0900;
ProvisioningStyle = Automatic;
};
F9C694561E40C720007084B6 = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = HZF422TY46;
LastSwiftMigration = 0900;
ProvisioningStyle = Automatic;
TestTargetID = F97C96761E1FDE25002D9E7E;
};
};
};
buildConfigurationList = F97C96721E1FDE25002D9E7E /* Build configuration list for PBXProject "FSPagerViewExample" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = F97C966E1E1FDE25002D9E7E;
productRefGroup = F97C96781E1FDE25002D9E7E /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
F97C96761E1FDE25002D9E7E /* FSPagerViewExample */,
F9C694561E40C720007084B6 /* FSPagerViewExampleUITests */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
F97C96751E1FDE25002D9E7E /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
F9C694321E40C583007084B6 /* Main.storyboard in Resources */,
F9C6947B1E40C8DA007084B6 /* 4.jpg in Resources */,
F9C6947A1E40C8DA007084B6 /* 3.jpg in Resources */,
F9C6947D1E40C8DA007084B6 /* 6.jpg in Resources */,
F9DF961F1E7F5B360010506C /* Assets.xcassets in Resources */,
F9C6947C1E40C8DA007084B6 /* 5.jpg in Resources */,
F9C694311E40C583007084B6 /* LaunchScreen.storyboard in Resources */,
F9C694791E40C8DA007084B6 /* 2.jpg in Resources */,
F9C6947E1E40C8DA007084B6 /* 7.jpg in Resources */,
F9C694711E40C8DA007084B6 /* 1.jpg in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
F9C694551E40C720007084B6 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
F97C96731E1FDE25002D9E7E /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
F9580B571E5D995400C5B267 /* FSPageControl.swift in Sources */,
F9580B581E5D995400C5B267 /* FSPagerCollectionView.swift in Sources */,
F9C6942F1E40C583007084B6 /* AppDelegate.swift in Sources */,
F954839A1E625F1E0069FD7E /* FSPagerViewLayoutAttributes.swift in Sources */,
F9580B591E5D995400C5B267 /* FSPagerView.swift in Sources */,
F9C694351E40C583007084B6 /* PageControlExampleViewController.swift in Sources */,
F9C694361E40C583007084B6 /* TransformerExampleViewController.swift in Sources */,
F9580B5C1E5D995400C5B267 /* FSPageViewTransformer.swift in Sources */,
F9C694331E40C583007084B6 /* BasicExampleViewController.swift in Sources */,
F9580B5A1E5D995400C5B267 /* FSPagerViewCell.swift in Sources */,
F9580B5B1E5D995400C5B267 /* FSPageViewLayout.swift in Sources */,
F931E00C2158A1F3001B2A01 /* FSPagerViewObjcCompat.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
F9C694531E40C720007084B6 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
F954839B1E625F1E0069FD7E /* FSPagerViewLayoutAttributes.swift in Sources */,
F9C6945A1E40C720007084B6 /* FSPagerViewExampleUITests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
F9C6945D1E40C720007084B6 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = F97C96761E1FDE25002D9E7E /* FSPagerViewExample */;
targetProxy = F9C6945C1E40C720007084B6 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
F9C694261E40C583007084B6 /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
F9C694271E40C583007084B6 /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "";
};
F9C694281E40C583007084B6 /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
F9C694291E40C583007084B6 /* Base */,
);
name = Main.storyboard;
sourceTree = "";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
F97C969D1E1FDE25002D9E7E /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
F97C969E1E1FDE25002D9E7E /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
F97C96A01E1FDE25002D9E7E /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = HZF422TY46;
INFOPLIST_FILE = "$(SRCROOT)/FSPagerViewExample/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.wenchaod.FSPagerViewExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
F97C96A11E1FDE25002D9E7E /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = HZF422TY46;
INFOPLIST_FILE = "$(SRCROOT)/FSPagerViewExample/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.wenchaod.FSPagerViewExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 5.0;
};
name = Release;
};
F9C6945F1E40C720007084B6 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
DEVELOPMENT_TEAM = HZF422TY46;
INFOPLIST_FILE = FSPagerViewExampleUITests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.2;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.wenchaod.FSPagerViewExampleUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 5.0;
TEST_TARGET_NAME = FSPagerViewExample;
};
name = Debug;
};
F9C694601E40C720007084B6 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
DEVELOPMENT_TEAM = HZF422TY46;
INFOPLIST_FILE = FSPagerViewExampleUITests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.2;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.wenchaod.FSPagerViewExampleUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 5.0;
TEST_TARGET_NAME = FSPagerViewExample;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
F97C96721E1FDE25002D9E7E /* Build configuration list for PBXProject "FSPagerViewExample" */ = {
isa = XCConfigurationList;
buildConfigurations = (
F97C969D1E1FDE25002D9E7E /* Debug */,
F97C969E1E1FDE25002D9E7E /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
F97C969F1E1FDE25002D9E7E /* Build configuration list for PBXNativeTarget "FSPagerViewExample" */ = {
isa = XCConfigurationList;
buildConfigurations = (
F97C96A01E1FDE25002D9E7E /* Debug */,
F97C96A11E1FDE25002D9E7E /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
F9C6945E1E40C720007084B6 /* Build configuration list for PBXNativeTarget "FSPagerViewExampleUITests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
F9C6945F1E40C720007084B6 /* Debug */,
F9C694601E40C720007084B6 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = F97C966F1E1FDE25002D9E7E /* Project object */;
}
================================================
FILE: FSPageViewExample-Swift/FSPagerViewExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata
================================================
================================================
FILE: FSPageViewExample-Swift/FSPagerViewExampleUITests/FSPagerViewExampleUITests.swift
================================================
//
// FSPagerViewExampleUITests.swift
// FSPagerViewExampleUITests
//
// Created by Wenchao Ding on 31/01/2017.
// Copyright © 2017 Wenchao Ding. All rights reserved.
//
import XCTest
class FSPagerViewExampleUITests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
// In UI tests it is usually best to stop immediately when a failure occurs.
continueAfterFailure = false
// UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
XCUIApplication().launch()
// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
// Use recording to get started writing UI tests.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
}
================================================
FILE: FSPageViewExample-Swift/FSPagerViewExampleUITests/Info.plist
================================================
CFBundleDevelopmentRegion
en
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIdentifier
$(PRODUCT_BUNDLE_IDENTIFIER)
CFBundleInfoDictionaryVersion
6.0
CFBundleName
$(PRODUCT_NAME)
CFBundlePackageType
BNDL
CFBundleShortVersionString
1.0
CFBundleVersion
1
================================================
FILE: FSPagerView/FSPagerView/FSPagerView.h
================================================
//
// FSPagerView.h
// FSPagerView
//
// Created by Wenchao Ding on 22/02/2017.
// Copyright © 2017 Wenchao Ding. All rights reserved.
//
#import
//! Project version number for FSPagerView.
FOUNDATION_EXPORT double FSPagerViewVersionNumber;
//! Project version string for FSPagerView.
FOUNDATION_EXPORT const unsigned char FSPagerViewVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import
================================================
FILE: FSPagerView/FSPagerView/Info.plist
================================================
CFBundleDevelopmentRegion
en
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIdentifier
$(PRODUCT_BUNDLE_IDENTIFIER)
CFBundleInfoDictionaryVersion
6.0
CFBundleName
$(PRODUCT_NAME)
CFBundlePackageType
FMWK
CFBundleShortVersionString
0.8.3
CFBundleVersion
$(CURRENT_PROJECT_VERSION)
NSPrincipalClass
================================================
FILE: FSPagerView/FSPagerView.xcodeproj/project.pbxproj
================================================
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
50C44A1D2150E7800093B3E9 /* FSPagerViewObjcCompat.h in Headers */ = {isa = PBXBuildFile; fileRef = 50C44A1C2150E7800093B3E9 /* FSPagerViewObjcCompat.h */; };
F931E0062158A062001B2A01 /* FSPagerViewObjcCompat.m in Sources */ = {isa = PBXBuildFile; fileRef = F931E0052158A062001B2A01 /* FSPagerViewObjcCompat.m */; };
F9580B7B1E5D9F0600C5B267 /* FSPagerView.h in Headers */ = {isa = PBXBuildFile; fileRef = F9580B791E5D9F0600C5B267 /* FSPagerView.h */; settings = {ATTRIBUTES = (Public, ); }; };
F9580B881E5D9F2B00C5B267 /* FSPageControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9580B821E5D9F2B00C5B267 /* FSPageControl.swift */; };
F9580B891E5D9F2B00C5B267 /* FSPagerCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9580B831E5D9F2B00C5B267 /* FSPagerCollectionView.swift */; };
F9580B8A1E5D9F2B00C5B267 /* FSPagerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9580B841E5D9F2B00C5B267 /* FSPagerView.swift */; };
F9580B8B1E5D9F2B00C5B267 /* FSPagerViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9580B851E5D9F2B00C5B267 /* FSPagerViewCell.swift */; };
F9580B8C1E5D9F2B00C5B267 /* FSPageViewLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9580B861E5D9F2B00C5B267 /* FSPageViewLayout.swift */; };
F9580B8D1E5D9F2B00C5B267 /* FSPageViewTransformer.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9580B871E5D9F2B00C5B267 /* FSPageViewTransformer.swift */; };
F9D7BD2A1E63DD5F003F6A0E /* FSPagerViewLayoutAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9D7BD291E63DD5F003F6A0E /* FSPagerViewLayoutAttributes.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
50C44A1C2150E7800093B3E9 /* FSPagerViewObjcCompat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FSPagerViewObjcCompat.h; sourceTree = ""; };
F931E0052158A062001B2A01 /* FSPagerViewObjcCompat.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FSPagerViewObjcCompat.m; sourceTree = ""; };
F9580B761E5D9F0600C5B267 /* FSPagerView.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = FSPagerView.framework; sourceTree = BUILT_PRODUCTS_DIR; };
F9580B791E5D9F0600C5B267 /* FSPagerView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FSPagerView.h; sourceTree = ""; };
F9580B7A1E5D9F0600C5B267 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
F9580B821E5D9F2B00C5B267 /* FSPageControl.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FSPageControl.swift; sourceTree = ""; };
F9580B831E5D9F2B00C5B267 /* FSPagerCollectionView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FSPagerCollectionView.swift; sourceTree = ""; };
F9580B841E5D9F2B00C5B267 /* FSPagerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FSPagerView.swift; sourceTree = ""; };
F9580B851E5D9F2B00C5B267 /* FSPagerViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FSPagerViewCell.swift; sourceTree = ""; };
F9580B861E5D9F2B00C5B267 /* FSPageViewLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FSPageViewLayout.swift; sourceTree = ""; };
F9580B871E5D9F2B00C5B267 /* FSPageViewTransformer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FSPageViewTransformer.swift; sourceTree = ""; };
F9D7BD291E63DD5F003F6A0E /* FSPagerViewLayoutAttributes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FSPagerViewLayoutAttributes.swift; sourceTree = ""; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
F9580B721E5D9F0600C5B267 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
F9580B6C1E5D9F0600C5B267 = {
isa = PBXGroup;
children = (
F9580B811E5D9F2B00C5B267 /* Sources */,
F9580B781E5D9F0600C5B267 /* FSPagerView */,
F9580B771E5D9F0600C5B267 /* Products */,
);
sourceTree = "";
};
F9580B771E5D9F0600C5B267 /* Products */ = {
isa = PBXGroup;
children = (
F9580B761E5D9F0600C5B267 /* FSPagerView.framework */,
);
name = Products;
sourceTree = "";
};
F9580B781E5D9F0600C5B267 /* FSPagerView */ = {
isa = PBXGroup;
children = (
F9580B791E5D9F0600C5B267 /* FSPagerView.h */,
F9580B7A1E5D9F0600C5B267 /* Info.plist */,
);
path = FSPagerView;
sourceTree = "";
};
F9580B811E5D9F2B00C5B267 /* Sources */ = {
isa = PBXGroup;
children = (
F9580B821E5D9F2B00C5B267 /* FSPageControl.swift */,
F9580B831E5D9F2B00C5B267 /* FSPagerCollectionView.swift */,
F9580B841E5D9F2B00C5B267 /* FSPagerView.swift */,
F9580B851E5D9F2B00C5B267 /* FSPagerViewCell.swift */,
F9580B861E5D9F2B00C5B267 /* FSPageViewLayout.swift */,
F9D7BD291E63DD5F003F6A0E /* FSPagerViewLayoutAttributes.swift */,
F9580B871E5D9F2B00C5B267 /* FSPageViewTransformer.swift */,
50C44A1C2150E7800093B3E9 /* FSPagerViewObjcCompat.h */,
F931E0052158A062001B2A01 /* FSPagerViewObjcCompat.m */,
);
name = Sources;
path = ../Sources;
sourceTree = "";
};
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
F9580B731E5D9F0600C5B267 /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
F9580B7B1E5D9F0600C5B267 /* FSPagerView.h in Headers */,
50C44A1D2150E7800093B3E9 /* FSPagerViewObjcCompat.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
F9580B751E5D9F0600C5B267 /* FSPagerView */ = {
isa = PBXNativeTarget;
buildConfigurationList = F9580B7E1E5D9F0600C5B267 /* Build configuration list for PBXNativeTarget "FSPagerView" */;
buildPhases = (
F9580B711E5D9F0600C5B267 /* Sources */,
F9580B721E5D9F0600C5B267 /* Frameworks */,
F9580B731E5D9F0600C5B267 /* Headers */,
F9580B741E5D9F0600C5B267 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = FSPagerView;
productName = FSPagerView;
productReference = F9580B761E5D9F0600C5B267 /* FSPagerView.framework */;
productType = "com.apple.product-type.framework";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
F9580B6D1E5D9F0600C5B267 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1030;
ORGANIZATIONNAME = "Wenchao Ding";
TargetAttributes = {
F9580B751E5D9F0600C5B267 = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = HZF422TY46;
LastSwiftMigration = 1000;
ProvisioningStyle = Automatic;
};
};
};
buildConfigurationList = F9580B701E5D9F0600C5B267 /* Build configuration list for PBXProject "FSPagerView" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = F9580B6C1E5D9F0600C5B267;
productRefGroup = F9580B771E5D9F0600C5B267 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
F9580B751E5D9F0600C5B267 /* FSPagerView */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
F9580B741E5D9F0600C5B267 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
F9580B711E5D9F0600C5B267 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
F9D7BD2A1E63DD5F003F6A0E /* FSPagerViewLayoutAttributes.swift in Sources */,
F9580B8D1E5D9F2B00C5B267 /* FSPageViewTransformer.swift in Sources */,
F9580B881E5D9F2B00C5B267 /* FSPageControl.swift in Sources */,
F9580B891E5D9F2B00C5B267 /* FSPagerCollectionView.swift in Sources */,
F9580B8C1E5D9F2B00C5B267 /* FSPageViewLayout.swift in Sources */,
F9580B8A1E5D9F2B00C5B267 /* FSPagerView.swift in Sources */,
F9580B8B1E5D9F2B00C5B267 /* FSPagerViewCell.swift in Sources */,
F931E0062158A062001B2A01 /* FSPagerViewObjcCompat.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
F9580B7C1E5D9F0600C5B267 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
name = Debug;
};
F9580B7D1E5D9F0600C5B267 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
name = Release;
};
F9580B7F1E5D9F0600C5B267 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = HZF422TY46;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = FSPagerView/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.wenchaod.FSPagerView;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
};
name = Debug;
};
F9580B801E5D9F0600C5B267 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = HZF422TY46;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = FSPagerView/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.wenchaod.FSPagerView;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
F9580B701E5D9F0600C5B267 /* Build configuration list for PBXProject "FSPagerView" */ = {
isa = XCConfigurationList;
buildConfigurations = (
F9580B7C1E5D9F0600C5B267 /* Debug */,
F9580B7D1E5D9F0600C5B267 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
F9580B7E1E5D9F0600C5B267 /* Build configuration list for PBXNativeTarget "FSPagerView" */ = {
isa = XCConfigurationList;
buildConfigurations = (
F9580B7F1E5D9F0600C5B267 /* Debug */,
F9580B801E5D9F0600C5B267 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = F9580B6D1E5D9F0600C5B267 /* Project object */;
}
================================================
FILE: FSPagerView/FSPagerView.xcodeproj/project.xcworkspace/contents.xcworkspacedata
================================================
================================================
FILE: FSPagerView/FSPagerView.xcodeproj/xcshareddata/xcschemes/FSPagerView.xcscheme
================================================
================================================
FILE: FSPagerView.podspec
================================================
Pod::Spec.new do |s|
s.name = "FSPagerView"
s.version = "0.8.3"
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"
s.screenshots = "https://cloud.githubusercontent.com/assets/5186464/22686432/19b567f8-ed5f-11e6-885d-bd660c98b507.gif"
s.license = 'MIT'
s.author = { "Wenchao Ding" => "f33chobits@gmail.com" }
s.source = { :git => "https://github.com/WenchaoD/FSPagerView.git", :tag => s.version.to_s }
s.platform = :ios
s.ios.deployment_target = '9.0'
s.requires_arc = true
s.framework = 'UIKit'
s.source_files = 'Sources/*.{swift,h,m}'
s.swift_version = '5.3'
s.cocoapods_version = '>= 1.4.0'
end
================================================
FILE: FSPagerViewExample-Objc/FSPagerViewExample-Objc/AppDelegate.h
================================================
//
// AppDelegate.h
// FSPagerViewExample-Objc
//
// Created by Wenchao Ding on 19/01/2017.
// Copyright © 2017 Wenchao Ding. All rights reserved.
//
#import
@interface AppDelegate : UIResponder
@property (strong, nonatomic) UIWindow *window;
@end
================================================
FILE: FSPagerViewExample-Objc/FSPagerViewExample-Objc/AppDelegate.m
================================================
//
// AppDelegate.m
// FSPagerViewExample-Objc
//
// Created by Wenchao Ding on 19/01/2017.
// Copyright © 2017 Wenchao Ding. All rights reserved.
//
#import "AppDelegate.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
@end
================================================
FILE: FSPagerViewExample-Objc/FSPagerViewExample-Objc/Base.lproj/LaunchScreen.storyboard
================================================
================================================
FILE: FSPagerViewExample-Objc/FSPagerViewExample-Objc/Base.lproj/Main.storyboard
================================================
================================================
FILE: FSPagerViewExample-Objc/FSPagerViewExample-Objc/BasicExampleViewController.h
================================================
//
// BasicExampleViewController.h
// FSPagerViewExample-Objc
//
// Created by Wenchao Ding on 19/01/2017.
// Copyright © 2017 Wenchao Ding. All rights reserved.
//
#import
@interface BasicExampleViewController : UIViewController
@end
================================================
FILE: FSPagerViewExample-Objc/FSPagerViewExample-Objc/BasicExampleViewController.m
================================================
//
// BasicExampleViewController.m
// FSPagerViewExample-Objc
//
// Created by Wenchao Ding on 19/01/2017.
// Copyright © 2017 Wenchao Ding. All rights reserved.
//
#import "BasicExampleViewController.h"
#import "FSPagerViewExample_Objc-Swift.h"
#import "FSPagerViewObjcCompat.h"
@interface BasicExampleViewController ()
@property (strong, nonatomic) NSArray *sectionTitles;
@property (strong, nonatomic) NSArray *configurationTitles;
@property (strong, nonatomic) NSArray *decelerationDistanceOptions;
@property (strong, nonatomic) NSArray *imageNames;
@property (assign, nonatomic) NSInteger numberOfItems;
@property (weak , nonatomic) IBOutlet UITableView *tableView;
@property (weak , nonatomic) IBOutlet FSPagerView *pagerView;
@property (weak , nonatomic) IBOutlet FSPageControl *pageControl;
- (IBAction)sliderValueChanged:(UISlider *)sender;
@end
@implementation BasicExampleViewController
#pragma mark - Life cycle
- (void)viewDidLoad
{
[super viewDidLoad];
self.sectionTitles = @[@"Configurations", @"Deceleration Distance", @"Item Size", @"Interitem Spacing", @"Number Of Items"];
self.configurationTitles = @[@"Automatic sliding", @"Infinite"];
self.decelerationDistanceOptions = @[@"Automatic", @"1", @"2"];
self.imageNames = @[@"1.jpg", @"2.jpg", @"3.jpg", @"4.jpg", @"5.jpg", @"6.jpg", @"7.jpg"];
self.numberOfItems = 7;
[self.pagerView registerClass:[FSPagerViewCell class] forCellWithReuseIdentifier:@"cell"];
self.pagerView.itemSize = FSPagerViewAutomaticSize;
self.pageControl.numberOfPages = self.imageNames.count;
self.pageControl.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
self.pageControl.contentInsets = UIEdgeInsetsMake(0, 20, 0, 20);
}
#pragma mark - UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return self.sectionTitles.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
switch (section) {
case 0:
return self.configurationTitles.count;
case 1:
return self.decelerationDistanceOptions.count;
case 2:
case 3:
case 4:
return 1;
default:
break;
}
return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
switch (indexPath.section) {
case 0: {
// Configurations
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
cell.textLabel.text = self.configurationTitles[indexPath.row];
if (indexPath.row == 0) {
// Automatic Sliding
cell.accessoryType = self.pagerView.automaticSlidingInterval > 0 ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
} else if (indexPath.row == 1) {
// IsInfinite
cell.accessoryType = self.pagerView.isInfinite ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
}
return cell;
}
case 1: {
// Decelaration Distance
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
cell.textLabel.text = self.decelerationDistanceOptions[indexPath.row];
switch (indexPath.row) {
case 0:
// Hardcode like '-1' is bad for readability, but there haven't been a better solution to export a swift constant to objective-c yet.
cell.accessoryType = self.pagerView.decelerationDistance == FSPagerViewAutomaticDistance ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
break;
case 1:
cell.accessoryType = self.pagerView.decelerationDistance == 1 ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
break;
case 2:
cell.accessoryType = self.pagerView.decelerationDistance == 2 ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
break;
default:
break;
}
return cell;
}
case 2: {
// Item Spacing
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"slider_cell"];
UISlider *slider = cell.contentView.subviews.firstObject;
slider.tag = 1;
slider.value = ({
CGFloat scale = self.pagerView.itemSize.width/self.pagerView.frame.size.width;
CGFloat value = (0.5-scale)*2;
value;
});
slider.continuous = YES;
return cell;
}
case 3: {
// Interitem Spacing
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"slider_cell"];
UISlider *slider = cell.contentView.subviews.firstObject;
slider.tag = 2;
slider.value = self.pagerView.interitemSpacing / 20.0;
slider.continuous = YES;
return cell;
}
case 4: {
// Number Of Items
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"slider_cell"];
UISlider *slider = cell.contentView.subviews.firstObject;
slider.tag = 3;
slider.value = self.numberOfItems / 7.0;
slider.minimumValue = 1.0 / 7;
slider.maximumValue = 1.0;
slider.continuous = NO;
return cell;
}
default:
break;
}
return [tableView dequeueReusableCellWithIdentifier:@"cell"];
}
#pragma mark - UITableViewDelegate
- (BOOL)tableView:(UITableView *)tableView shouldHighlightRowAtIndexPath:(NSIndexPath *)indexPath
{
return indexPath.section == 0 || indexPath.section == 1;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
switch (indexPath.section) {
case 0: {
if (indexPath.row == 0) {
// Automatic Sliding
self.pagerView.automaticSlidingInterval = 3.0 - self.pagerView.automaticSlidingInterval;
} else if (indexPath.row == 1) {
// IsInfinite
self.pagerView.isInfinite = !self.pagerView.isInfinite;
}
[tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationAutomatic];
break;
}
case 1: {
switch (indexPath.row) {
case 0:
self.pagerView.decelerationDistance = FSPagerViewAutomaticDistance;
break;
case 1:
self.pagerView.decelerationDistance = 1;
break;
case 2:
self.pagerView.decelerationDistance = 2;
break;
default:
break;
}
[tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationAutomatic];
break;
}
default:
break;
}
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return self.sectionTitles[section];
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return section == 0 ? 40 : 20;
}
#pragma mark - FSPagerViewDataSource
- (NSInteger)numberOfItemsInPagerView:(FSPagerView *)pagerView
{
return self.numberOfItems;
}
- (FSPagerViewCell *)pagerView:(FSPagerView *)pagerView cellForItemAtIndex:(NSInteger)index
{
FSPagerViewCell *cell = [pagerView dequeueReusableCellWithReuseIdentifier:@"cell" atIndex:index];
cell.imageView.image = [UIImage imageNamed:self.imageNames[index]];
cell.imageView.contentMode = UIViewContentModeScaleAspectFill;
cell.imageView.clipsToBounds = YES;
cell.textLabel.text = [NSString stringWithFormat:@"%@%@",@(index),@(index)];
return cell;
}
#pragma mark - FSPagerView Delegate
- (void)pagerView:(FSPagerView *)pagerView didSelectItemAtIndex:(NSInteger)index
{
[pagerView deselectItemAtIndex:index animated:YES];
[pagerView scrollToItemAtIndex:index animated:YES];
}
- (void)pagerViewWillEndDragging:(FSPagerView *)pagerView targetIndex:(NSInteger)targetIndex
{
self.pageControl.currentPage = targetIndex;
}
- (void)pagerViewDidEndScrollAnimation:(FSPagerView *)pagerView
{
self.pageControl.currentPage = pagerView.currentIndex;
}
#pragma mark - Target actions
- (void)sliderValueChanged:(UISlider *)sender
{
switch (sender.tag) {
case 1: {
CGFloat scale = 0.5 * (1 + sender.value); // [0.5 - 1.0]
self.pagerView.itemSize = CGSizeApplyAffineTransform(self.pagerView.frame.size, CGAffineTransformMakeScale(scale, scale));
break;
}
case 2: {
self.pagerView.interitemSpacing = sender.value * 20; // [0 - 20]
break;
}
case 3: {
self.numberOfItems = roundf(sender.value * 7);
self.pageControl.numberOfPages = self.numberOfItems;
[self.pagerView reloadData];
break;
}
default:
break;
}
}
@end
================================================
FILE: FSPagerViewExample-Objc/FSPagerViewExample-Objc/Info.plist
================================================
CFBundleDevelopmentRegion
en
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIdentifier
$(PRODUCT_BUNDLE_IDENTIFIER)
CFBundleInfoDictionaryVersion
6.0
CFBundleName
$(PRODUCT_NAME)
CFBundlePackageType
APPL
CFBundleShortVersionString
1.0
CFBundleVersion
1
LSRequiresIPhoneOS
UILaunchStoryboardName
LaunchScreen
UIMainStoryboardFile
Main
UIRequiredDeviceCapabilities
armv7
UISupportedInterfaceOrientations
UIInterfaceOrientationPortrait
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
UISupportedInterfaceOrientations~ipad
UIInterfaceOrientationPortrait
UIInterfaceOrientationPortraitUpsideDown
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
================================================
FILE: FSPagerViewExample-Objc/FSPagerViewExample-Objc/PageControlExampleViewController.h
================================================
//
// PageControlExampleViewController.h
// FSPagerViewExample-Objc
//
// Created by Wenchao Ding on 20/01/2017.
// Copyright © 2017 Wenchao Ding. All rights reserved.
//
#import
@interface PageControlExampleViewController : UIViewController
@end
================================================
FILE: FSPagerViewExample-Objc/FSPagerViewExample-Objc/PageControlExampleViewController.m
================================================
//
// PageControlExampleViewController.m
// FSPagerViewExample-Objc
//
// Created by Wenchao Ding on 20/01/2017.
// Copyright © 2017 Wenchao Ding. All rights reserved.
//
#import "PageControlExampleViewController.h"
#import "FSPagerViewExample_Objc-Swift.h"
#import "FSPagerViewObjcCompat.h"
@interface PageControlExampleViewController ()
@property (strong, nonatomic) NSArray *imageNames;
@property (strong, nonatomic) NSArray *pageControlStyles;
@property (strong, nonatomic) NSArray *pageControlAlignments;
@property (strong, nonatomic) NSArray *sectionTitles;
@property (weak , nonatomic) IBOutlet UITableView *tableView;
@property (weak , nonatomic) IBOutlet FSPagerView *pagerView;
@property (weak , nonatomic) IBOutlet FSPageControl *pageControl;
@property (assign, nonatomic) NSInteger styleIndex;
@property (assign, nonatomic) NSInteger alignmentIndex;
// ⭐️
@property (readonly, nonatomic) UIBezierPath *starPath;
// ❤️
@property (readonly, nonatomic) UIBezierPath *heartPath;
- (IBAction)sliderValueChanged:(UISlider *)sender;
@end
@implementation PageControlExampleViewController
#pragma mark - Life cycle
- (void)viewDidLoad
{
[super viewDidLoad];
self.imageNames = @[@"1.jpg", @"2.jpg", @"3.jpg", @"4.jpg", @"5.jpg", @"6.jpg", @"7.jpg"];
self.pageControlStyles = @[@"Default", @"Ring", @"UIImage", @"UIBezierPath - Star", @"UIBezierPath - Heart"];
self.pageControlAlignments = @[@"Right", @"Center", @"Left"];
self.sectionTitles = @[@"Style", @"Item Spacing", @"Interitem Spacing", @"Horizontal Alignment"];
self.pageControl.numberOfPages = self.imageNames.count;
self.pageControl.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
self.pageControl.contentInsets = UIEdgeInsetsMake(0, 20, 0, 20);
self.pagerView.itemSize = FSPagerViewAutomaticSize; // Fill parent
[self.pagerView registerClass:[FSPagerViewCell class] forCellWithReuseIdentifier:@"cell"];
}
#pragma mark - UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return self.sectionTitles.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
switch (section) {
case 0:
return self.pageControlStyles.count;
case 1:
case 2:
return 1;
case 3:
return self.pageControlAlignments.count;
default:
break;
}
return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
switch (indexPath.section) {
case 0: {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
cell.textLabel.text = self.pageControlStyles[indexPath.row];
cell.accessoryType = self.styleIndex==indexPath.row ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
return cell;
}
case 1: {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"slider_cell"];
UISlider *slider = cell.contentView.subviews.firstObject;
slider.tag = indexPath.section;
slider.value = (self.pageControl.itemSpacing-6.0)/10.0;
return cell;
}
case 2: {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"slider_cell"];
UISlider *slider = cell.contentView.subviews.firstObject;
slider.tag = indexPath.section;
slider.value = (self.pageControl.interitemSpacing-6.0)/10.0;
return cell;
}
case 3: {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
cell.textLabel.text = self.pageControlAlignments[indexPath.row];
cell.accessoryType = self.alignmentIndex==indexPath.row ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
return cell;
}
default:
break;
}
return [tableView dequeueReusableCellWithIdentifier:@"cell"];
}
#pragma mark - UITableViewDelegate
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return self.sectionTitles[section];
}
- (BOOL)tableView:(UITableView *)tableView shouldHighlightRowAtIndexPath:(NSIndexPath *)indexPath
{
return indexPath.section == 0 || indexPath.section == 3;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
switch (indexPath.section) {
case 0: {
self.styleIndex = indexPath.row;
[tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationAutomatic];
break;
}
case 3: {
self.alignmentIndex = indexPath.row;
[tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationAutomatic];
break;
}
default:
break;
}
}
#pragma mark - FSPagerViewDataSource
- (NSInteger)numberOfItemsInPagerView:(FSPagerView *)pagerView
{
return self.imageNames.count;
}
- (FSPagerViewCell *)pagerView:(FSPagerView *)pagerView cellForItemAtIndex:(NSInteger)index
{
FSPagerViewCell *cell = [pagerView dequeueReusableCellWithReuseIdentifier:@"cell" atIndex:index];
cell.imageView.contentMode = UIViewContentModeScaleAspectFill;
cell.imageView.image = [UIImage imageNamed:self.imageNames[index]];
return cell;
}
#pragma mark - FSPagerViewDelegate
- (void)pagerViewWillEndDragging:(FSPagerView *)pagerView targetIndex:(NSInteger)targetIndex
{
self.pageControl.currentPage = targetIndex;
}
#pragma mark - Target actions
- (void)sliderValueChanged:(UISlider *)sender
{
switch (sender.tag) {
case 1: {
self.pageControl.itemSpacing = 6.0 + sender.value*10.0; // [6 - 16]
// Redraw UIBezierPath
if (self.styleIndex == 3 || self.styleIndex == 4) {
self.styleIndex = self.styleIndex;
}
break;
}
case 2: {
self.pageControl.interitemSpacing = 6.0 + sender.value*10.0; // [6 - 16]
break;
}
default:
break;
}
}
#pragma mark - Private properties
- (void)setStyleIndex:(NSInteger)styleIndex
{
_styleIndex = styleIndex;
// Clean up
[self.pageControl setStrokeColor:nil forState:UIControlStateNormal];
[self.pageControl setStrokeColor:nil forState:UIControlStateSelected];
[self.pageControl setFillColor:nil forState:UIControlStateNormal];
[self.pageControl setFillColor:nil forState:UIControlStateSelected];
[self.pageControl setImage:nil forState:UIControlStateNormal];
[self.pageControl setImage:nil forState:UIControlStateSelected];
[self.pageControl setPath:nil forState:UIControlStateNormal];
[self.pageControl setPath:nil forState:UIControlStateSelected];
switch (styleIndex) {
case 0: {
// Default
break;
}
case 1: {
// Ring
[self.pageControl setStrokeColor:[UIColor greenColor] forState:UIControlStateNormal];
[self.pageControl setStrokeColor:[UIColor greenColor] forState:UIControlStateSelected];
[self.pageControl setFillColor:[UIColor greenColor] forState:UIControlStateSelected];
break;
}
case 2: {
// UIImage
[self.pageControl setImage:[UIImage imageNamed:@"icon_footprint"] forState:UIControlStateNormal];
[self.pageControl setImage:[UIImage imageNamed:@"icon_cat"] forState:UIControlStateSelected];
break;
}
case 3: {
// UIBezierPath - Star
[self.pageControl setStrokeColor:[UIColor yellowColor] forState:UIControlStateNormal];
[self.pageControl setStrokeColor:[UIColor yellowColor] forState:UIControlStateSelected];
[self.pageControl setFillColor:[UIColor yellowColor] forState:UIControlStateSelected];
[self.pageControl setPath:self.starPath forState:UIControlStateNormal];
[self.pageControl setPath:self.starPath forState:UIControlStateSelected];
break;
}
case 4: {
// UIBezierPath - Heart
UIColor *color = [UIColor colorWithRed:255/255.0 green:102/255.0 blue:255/255.0 alpha:1.0];
[self.pageControl setStrokeColor:color forState:UIControlStateNormal];
[self.pageControl setStrokeColor:color forState:UIControlStateSelected];
[self.pageControl setFillColor:color forState:UIControlStateSelected];
[self.pageControl setPath:self.heartPath forState:UIControlStateNormal];
[self.pageControl setPath:self.heartPath forState:UIControlStateSelected];
break;
}
default:
break;
}
}
- (void)setAlignmentIndex:(NSInteger)alignmentIndex
{
_alignmentIndex = alignmentIndex;
switch (alignmentIndex) {
case 0: {
self.pageControl.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
break;
}
case 1: {
self.pageControl.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
break;
}
case 2: {
self.pageControl.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
break;
}
default:
break;
}
}
// ⭐️
- (UIBezierPath *)starPath
{
CGFloat width = self.pageControl.itemSpacing;
CGFloat height = self.pageControl.itemSpacing;
UIBezierPath *starPath = [[UIBezierPath alloc] init];
[starPath moveToPoint:CGPointMake(width*0.5, 0)];
[starPath addLineToPoint:CGPointMake(width*0.677, height*0.257)];
[starPath addLineToPoint:CGPointMake(width*0.975, height*0.345)];
[starPath addLineToPoint:CGPointMake(width*0.785, height*0.593)];
[starPath addLineToPoint:CGPointMake(width*0.794, height*0.905)];
[starPath addLineToPoint:CGPointMake(width*0.5, height*0.8)];
[starPath addLineToPoint:CGPointMake(width*0.206, height*0.905)];
[starPath addLineToPoint:CGPointMake(width*0.215, height*0.593)];
[starPath addLineToPoint:CGPointMake(width*0.025, height*0.345)];
[starPath addLineToPoint:CGPointMake(width*0.323, height*0.257)];
[starPath closePath];
return starPath;
}
// ❤️
- (UIBezierPath *)heartPath
{
CGFloat width = self.pageControl.itemSpacing;
CGFloat height = self.pageControl.itemSpacing;
UIBezierPath *heartPath = [[UIBezierPath alloc] init];
[heartPath moveToPoint:CGPointMake(width*0.5, height)];
[heartPath addCurveToPoint:CGPointMake(0, height*0.25)
controlPoint1:CGPointMake(width*0.5, height*0.75)
controlPoint2:CGPointMake(0, height*0.5)];
[heartPath addArcWithCenter:CGPointMake(width*0.25, height*0.25)
radius:width*0.25
startAngle:M_PI
endAngle:0
clockwise:YES];
[heartPath addArcWithCenter:CGPointMake(width*0.75, height*0.25)
radius:width*0.25
startAngle:M_PI
endAngle:0
clockwise:YES];
[heartPath addCurveToPoint:CGPointMake(width*0.5, height)
controlPoint1:CGPointMake(width, height*0.5)
controlPoint2:CGPointMake(width*0.5, height*0.75)];
[heartPath closePath];
return heartPath;
}
@end
================================================
FILE: FSPagerViewExample-Objc/FSPagerViewExample-Objc/TransformerExampleViewController.h
================================================
//
// ViewController.h
// FSPagerViewExample-Objc
//
// Created by Wenchao Ding on 19/01/2017.
// Copyright © 2017 Wenchao Ding. All rights reserved.
//
#import
@interface TransformerExampleViewController : UIViewController
@end
================================================
FILE: FSPagerViewExample-Objc/FSPagerViewExample-Objc/TransformerExampleViewController.m
================================================
//
// TransformerExampleViewController.m
// FSPagerViewExample-Objc
//
// Created by Wenchao Ding on 19/01/2017.
// Copyright © 2017 Wenchao Ding. All rights reserved.
//
#import "TransformerExampleViewController.h"
#import "FSPagerViewExample_Objc-Swift.h"
#import "FSPagerViewObjcCompat.h"
@interface TransformerExampleViewController ()
@property (strong, nonatomic) NSArray *imageNames;
@property (strong, nonatomic) NSArray *transformerNames;
@property (assign, nonatomic) NSInteger typeIndex;
@property (weak , nonatomic) IBOutlet UITableView *tableView;
@property (weak , nonatomic) IBOutlet FSPagerView *pagerView;
@end
@implementation TransformerExampleViewController
#pragma mark - Life cycle
- (void)viewDidLoad
{
[super viewDidLoad];
self.imageNames = @[@"1.jpg", @"2.jpg", @"3.jpg", @"4.jpg", @"5.jpg", @"6.jpg", @"7.jpg"];
self.transformerNames = @[@"cross fading", @"zoom out", @"depth", @"linear", @"overlap", @"ferris wheel", @"inverted ferris wheel", @"coverflow", @"cubic"];
[self.pagerView registerClass:[FSPagerViewCell class] forCellWithReuseIdentifier:@"cell"];
self.pagerView.isInfinite = YES;
self.typeIndex = 0;
}
- (void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
self.typeIndex = self.typeIndex;
}
#pragma mark - UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.transformerNames.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
cell.textLabel.text = self.transformerNames[indexPath.row];
cell.accessoryType = indexPath.row == self.typeIndex ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
self.typeIndex = indexPath.row;
[tableView reloadRowsAtIndexPaths:tableView.indexPathsForVisibleRows withRowAnimation:UITableViewRowAnimationAutomatic];
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return @"Transformers";
}
#pragma mark - FSPagerViewDataSource
- (NSInteger)numberOfItemsInPagerView:(FSPagerView *)pagerView
{
return self.imageNames.count;
}
- (FSPagerViewCell *)pagerView:(FSPagerView *)pagerView cellForItemAtIndex:(NSInteger)index
{
FSPagerViewCell * cell = [pagerView dequeueReusableCellWithReuseIdentifier:@"cell" atIndex:index];
cell.imageView.image = [UIImage imageNamed:self.imageNames[index]];
cell.imageView.contentMode = UIViewContentModeScaleAspectFill;
cell.imageView.clipsToBounds = YES;
return cell;
}
#pragma mark - FSPagerViewDelegate
- (void)pagerView:(FSPagerView *)pagerView didSelectItemAtIndex:(NSInteger)index
{
[pagerView deselectItemAtIndex:index animated:YES];
[pagerView scrollToItemAtIndex:index animated:YES];
}
#pragma mark - Private properties
- (void)setTypeIndex:(NSInteger)typeIndex
{
_typeIndex = typeIndex;
FSPagerViewTransformerType type;
switch (typeIndex) {
case 0: {
type = FSPagerViewTransformerTypeCrossFading;
break;
}
case 1: {
type = FSPagerViewTransformerTypeZoomOut;
break;
}
case 2: {
type = FSPagerViewTransformerTypeDepth;
break;
}
case 3: {
type = FSPagerViewTransformerTypeLinear;
break;
}
case 4: {
type = FSPagerViewTransformerTypeOverlap;
break;
}
case 5: {
type = FSPagerViewTransformerTypeFerrisWheel;
break;
}
case 6: {
type = FSPagerViewTransformerTypeInvertedFerrisWheel;
break;
}
case 7: {
type = FSPagerViewTransformerTypeCoverFlow;
break;
}
case 8: {
type = FSPagerViewTransformerTypeCubic;
break;
}
default:
type = FSPagerViewTransformerTypeZoomOut;
break;
}
self.pagerView.transformer = [[FSPagerViewTransformer alloc] initWithType:type];
switch (type) {
case FSPagerViewTransformerTypeCrossFading:
case FSPagerViewTransformerTypeZoomOut:
case FSPagerViewTransformerTypeDepth: {
self.pagerView.itemSize = FSPagerViewAutomaticSize;
self.pagerView.decelerationDistance = 1;
break;
}
case FSPagerViewTransformerTypeLinear:
case FSPagerViewTransformerTypeOverlap: {
CGAffineTransform transform = CGAffineTransformMakeScale(0.6, 0.75);
self.pagerView.itemSize = CGSizeApplyAffineTransform(self.pagerView.frame.size, transform);
self.pagerView.decelerationDistance = FSPagerViewAutomaticDistance;
break;
}
case FSPagerViewTransformerTypeFerrisWheel:
case FSPagerViewTransformerTypeInvertedFerrisWheel: {
self.pagerView.itemSize = CGSizeMake(180, 140);
self.pagerView.decelerationDistance = FSPagerViewAutomaticDistance;
break;
}
case FSPagerViewTransformerTypeCoverFlow: {
self.pagerView.itemSize = CGSizeMake(220, 170);
self.pagerView.decelerationDistance = FSPagerViewAutomaticDistance;
break;
}
case FSPagerViewTransformerTypeCubic: {
CGAffineTransform transform = CGAffineTransformMakeScale(0.9, 0.9);
self.pagerView.itemSize = CGSizeApplyAffineTransform(self.pagerView.frame.size, transform);
self.pagerView.decelerationDistance = 1;
break;
}
default:
break;
}
}
@end
================================================
FILE: FSPagerViewExample-Objc/FSPagerViewExample-Objc/main.m
================================================
//
// main.m
// FSPagerViewExample-Objc
//
// Created by Wenchao Ding on 19/01/2017.
// Copyright © 2017 Wenchao Ding. All rights reserved.
//
#import
#import "AppDelegate.h"
int main(int argc, char * argv[]) {
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
================================================
FILE: FSPagerViewExample-Objc/FSPagerViewExample-Objc.xcodeproj/project.pbxproj
================================================
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
F908BC411E35AAE4002B2F51 /* 1.jpg in Resources */ = {isa = PBXBuildFile; fileRef = F908BC321E35AAE4002B2F51 /* 1.jpg */; };
F908BC491E35AAE4002B2F51 /* 2.jpg in Resources */ = {isa = PBXBuildFile; fileRef = F908BC3A1E35AAE4002B2F51 /* 2.jpg */; };
F908BC4A1E35AAE4002B2F51 /* 3.jpg in Resources */ = {isa = PBXBuildFile; fileRef = F908BC3B1E35AAE4002B2F51 /* 3.jpg */; };
F908BC4B1E35AAE4002B2F51 /* 4.jpg in Resources */ = {isa = PBXBuildFile; fileRef = F908BC3C1E35AAE4002B2F51 /* 4.jpg */; };
F908BC4C1E35AAE4002B2F51 /* 5.jpg in Resources */ = {isa = PBXBuildFile; fileRef = F908BC3D1E35AAE4002B2F51 /* 5.jpg */; };
F908BC4D1E35AAE4002B2F51 /* 6.jpg in Resources */ = {isa = PBXBuildFile; fileRef = F908BC3E1E35AAE4002B2F51 /* 6.jpg */; };
F908BC4E1E35AAE4002B2F51 /* 7.jpg in Resources */ = {isa = PBXBuildFile; fileRef = F908BC3F1E35AAE4002B2F51 /* 7.jpg */; };
F931E00A2158A1E4001B2A01 /* FSPagerViewObjcCompat.m in Sources */ = {isa = PBXBuildFile; fileRef = F931E0092158A1E4001B2A01 /* FSPagerViewObjcCompat.m */; };
F93F5E141E319AE8006B7082 /* PageControlExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F93F5E131E319AE8006B7082 /* PageControlExampleViewController.m */; };
F9580B641E5D997200C5B267 /* FSPageControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9580B5E1E5D997200C5B267 /* FSPageControl.swift */; };
F9580B651E5D997200C5B267 /* FSPagerCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9580B5F1E5D997200C5B267 /* FSPagerCollectionView.swift */; };
F9580B661E5D997200C5B267 /* FSPagerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9580B601E5D997200C5B267 /* FSPagerView.swift */; };
F9580B671E5D997200C5B267 /* FSPagerViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9580B611E5D997200C5B267 /* FSPagerViewCell.swift */; };
F9580B681E5D997200C5B267 /* FSPageViewLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9580B621E5D997200C5B267 /* FSPageViewLayout.swift */; };
F9580B691E5D997200C5B267 /* FSPageViewTransformer.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9580B631E5D997200C5B267 /* FSPageViewTransformer.swift */; };
F9C6944C1E40C6C1007084B6 /* FSPagerViewExample_ObjcUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9C6944B1E40C6C1007084B6 /* FSPagerViewExample_ObjcUITests.swift */; };
F9DF961D1E7F5B240010506C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F9DF961C1E7F5B240010506C /* Assets.xcassets */; };
F9EC371E1E304A830022B6D6 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = F9EC371D1E304A830022B6D6 /* main.m */; };
F9EC37211E304A830022B6D6 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = F9EC37201E304A830022B6D6 /* AppDelegate.m */; };
F9EC37241E304A830022B6D6 /* BasicExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F9EC37231E304A830022B6D6 /* BasicExampleViewController.m */; };
F9EC37271E304A830022B6D6 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F9EC37251E304A830022B6D6 /* Main.storyboard */; };
F9EC372C1E304A830022B6D6 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F9EC372A1E304A830022B6D6 /* LaunchScreen.storyboard */; };
F9F00A901E310FF600790735 /* TransformerExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F9F00A8F1E310FF600790735 /* TransformerExampleViewController.m */; };
F9FF349F1E65B38C001E943F /* FSPagerViewLayoutAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9FF349E1E65B38C001E943F /* FSPagerViewLayoutAttributes.swift */; };
F9FF34A01E65B38C001E943F /* FSPagerViewLayoutAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9FF349E1E65B38C001E943F /* FSPagerViewLayoutAttributes.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
F9C6944E1E40C6C1007084B6 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = F9EC37111E304A830022B6D6 /* Project object */;
proxyType = 1;
remoteGlobalIDString = F9EC37181E304A830022B6D6;
remoteInfo = "FSPagerViewExample-Objc";
};
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
50989DFD2151DB25004DBB4A /* FSPagerViewObjcCompat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FSPagerViewObjcCompat.h; sourceTree = ""; };
F908BC321E35AAE4002B2F51 /* 1.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 1.jpg; sourceTree = ""; };
F908BC3A1E35AAE4002B2F51 /* 2.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 2.jpg; sourceTree = ""; };
F908BC3B1E35AAE4002B2F51 /* 3.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 3.jpg; sourceTree = ""; };
F908BC3C1E35AAE4002B2F51 /* 4.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 4.jpg; sourceTree = ""; };
F908BC3D1E35AAE4002B2F51 /* 5.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 5.jpg; sourceTree = ""; };
F908BC3E1E35AAE4002B2F51 /* 6.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 6.jpg; sourceTree = ""; };
F908BC3F1E35AAE4002B2F51 /* 7.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 7.jpg; sourceTree = ""; };
F931E0092158A1E4001B2A01 /* FSPagerViewObjcCompat.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FSPagerViewObjcCompat.m; sourceTree = ""; };
F93F5E121E319AE8006B7082 /* PageControlExampleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageControlExampleViewController.h; sourceTree = ""; };
F93F5E131E319AE8006B7082 /* PageControlExampleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PageControlExampleViewController.m; sourceTree = ""; };
F9580B5E1E5D997200C5B267 /* FSPageControl.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FSPageControl.swift; sourceTree = ""; };
F9580B5F1E5D997200C5B267 /* FSPagerCollectionView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FSPagerCollectionView.swift; sourceTree = ""; };
F9580B601E5D997200C5B267 /* FSPagerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FSPagerView.swift; sourceTree = ""; };
F9580B611E5D997200C5B267 /* FSPagerViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FSPagerViewCell.swift; sourceTree = ""; };
F9580B621E5D997200C5B267 /* FSPageViewLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FSPageViewLayout.swift; sourceTree = ""; };
F9580B631E5D997200C5B267 /* FSPageViewTransformer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FSPageViewTransformer.swift; sourceTree = ""; };
F9C694491E40C6C1007084B6 /* FSPagerViewExample-ObjcUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "FSPagerViewExample-ObjcUITests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
F9C6944B1E40C6C1007084B6 /* FSPagerViewExample_ObjcUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FSPagerViewExample_ObjcUITests.swift; sourceTree = ""; };
F9C6944D1E40C6C1007084B6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
F9DF961C1E7F5B240010506C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
F9EC37191E304A830022B6D6 /* FSPagerViewExample-Objc.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "FSPagerViewExample-Objc.app"; sourceTree = BUILT_PRODUCTS_DIR; };
F9EC371D1E304A830022B6D6 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
F9EC371F1E304A830022B6D6 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
F9EC37201E304A830022B6D6 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
F9EC37221E304A830022B6D6 /* BasicExampleViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BasicExampleViewController.h; sourceTree = ""; };
F9EC37231E304A830022B6D6 /* BasicExampleViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BasicExampleViewController.m; sourceTree = ""; };
F9EC37261E304A830022B6D6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
F9EC372B1E304A830022B6D6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
F9EC372D1E304A830022B6D6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
F9F00A8E1E310FF600790735 /* TransformerExampleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TransformerExampleViewController.h; sourceTree = ""; };
F9F00A8F1E310FF600790735 /* TransformerExampleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TransformerExampleViewController.m; sourceTree = ""; };
F9FF349E1E65B38C001E943F /* FSPagerViewLayoutAttributes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FSPagerViewLayoutAttributes.swift; sourceTree = ""; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
F9C694461E40C6C1007084B6 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
F9EC37161E304A830022B6D6 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
F908BC311E35AAE4002B2F51 /* Resources */ = {
isa = PBXGroup;
children = (
F9DF961C1E7F5B240010506C /* Assets.xcassets */,
F908BC321E35AAE4002B2F51 /* 1.jpg */,
F908BC3A1E35AAE4002B2F51 /* 2.jpg */,
F908BC3B1E35AAE4002B2F51 /* 3.jpg */,
F908BC3C1E35AAE4002B2F51 /* 4.jpg */,
F908BC3D1E35AAE4002B2F51 /* 5.jpg */,
F908BC3E1E35AAE4002B2F51 /* 6.jpg */,
F908BC3F1E35AAE4002B2F51 /* 7.jpg */,
);
name = Resources;
path = ../../Resources;
sourceTree = "";
};
F9580B5D1E5D997200C5B267 /* Sources */ = {
isa = PBXGroup;
children = (
F9580B5E1E5D997200C5B267 /* FSPageControl.swift */,
F9580B5F1E5D997200C5B267 /* FSPagerCollectionView.swift */,
F9580B601E5D997200C5B267 /* FSPagerView.swift */,
F9580B611E5D997200C5B267 /* FSPagerViewCell.swift */,
F9580B621E5D997200C5B267 /* FSPageViewLayout.swift */,
F9FF349E1E65B38C001E943F /* FSPagerViewLayoutAttributes.swift */,
F9580B631E5D997200C5B267 /* FSPageViewTransformer.swift */,
50989DFD2151DB25004DBB4A /* FSPagerViewObjcCompat.h */,
F931E0092158A1E4001B2A01 /* FSPagerViewObjcCompat.m */,
);
name = Sources;
path = ../Sources;
sourceTree = "";
};
F9C6944A1E40C6C1007084B6 /* FSPagerViewExample-ObjcUITests */ = {
isa = PBXGroup;
children = (
F9C6944B1E40C6C1007084B6 /* FSPagerViewExample_ObjcUITests.swift */,
F9C6944D1E40C6C1007084B6 /* Info.plist */,
);
path = "FSPagerViewExample-ObjcUITests";
sourceTree = "";
};
F9C870F71E30FF8B005786E9 /* Basic Example */ = {
isa = PBXGroup;
children = (
F9EC37221E304A830022B6D6 /* BasicExampleViewController.h */,
F9EC37231E304A830022B6D6 /* BasicExampleViewController.m */,
);
name = "Basic Example";
sourceTree = "";
};
F9C870F81E30FFA0005786E9 /* Transformer Example */ = {
isa = PBXGroup;
children = (
F9F00A8E1E310FF600790735 /* TransformerExampleViewController.h */,
F9F00A8F1E310FF600790735 /* TransformerExampleViewController.m */,
);
name = "Transformer Example";
sourceTree = "";
};
F9C870F91E30FFAB005786E9 /* PageControl Example */ = {
isa = PBXGroup;
children = (
F93F5E121E319AE8006B7082 /* PageControlExampleViewController.h */,
F93F5E131E319AE8006B7082 /* PageControlExampleViewController.m */,
);
name = "PageControl Example";
sourceTree = "";
};
F9EC37101E304A830022B6D6 = {
isa = PBXGroup;
children = (
F9580B5D1E5D997200C5B267 /* Sources */,
F9EC371B1E304A830022B6D6 /* FSPagerViewExample-Objc */,
F9C6944A1E40C6C1007084B6 /* FSPagerViewExample-ObjcUITests */,
F9EC371A1E304A830022B6D6 /* Products */,
);
sourceTree = "";
};
F9EC371A1E304A830022B6D6 /* Products */ = {
isa = PBXGroup;
children = (
F9EC37191E304A830022B6D6 /* FSPagerViewExample-Objc.app */,
F9C694491E40C6C1007084B6 /* FSPagerViewExample-ObjcUITests.xctest */,
);
name = Products;
sourceTree = "";
};
F9EC371B1E304A830022B6D6 /* FSPagerViewExample-Objc */ = {
isa = PBXGroup;
children = (
F9EC371F1E304A830022B6D6 /* AppDelegate.h */,
F9EC37201E304A830022B6D6 /* AppDelegate.m */,
F9C870F71E30FF8B005786E9 /* Basic Example */,
F9C870F81E30FFA0005786E9 /* Transformer Example */,
F9C870F91E30FFAB005786E9 /* PageControl Example */,
F9EC37251E304A830022B6D6 /* Main.storyboard */,
F9EC372A1E304A830022B6D6 /* LaunchScreen.storyboard */,
F9EC372D1E304A830022B6D6 /* Info.plist */,
F908BC311E35AAE4002B2F51 /* Resources */,
F9EC371C1E304A830022B6D6 /* Supporting Files */,
);
path = "FSPagerViewExample-Objc";
sourceTree = "";
};
F9EC371C1E304A830022B6D6 /* Supporting Files */ = {
isa = PBXGroup;
children = (
F9EC371D1E304A830022B6D6 /* main.m */,
);
name = "Supporting Files";
sourceTree = "";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
F9C694481E40C6C1007084B6 /* FSPagerViewExample-ObjcUITests */ = {
isa = PBXNativeTarget;
buildConfigurationList = F9C694501E40C6C1007084B6 /* Build configuration list for PBXNativeTarget "FSPagerViewExample-ObjcUITests" */;
buildPhases = (
F9C694451E40C6C1007084B6 /* Sources */,
F9C694461E40C6C1007084B6 /* Frameworks */,
F9C694471E40C6C1007084B6 /* Resources */,
);
buildRules = (
);
dependencies = (
F9C6944F1E40C6C1007084B6 /* PBXTargetDependency */,
);
name = "FSPagerViewExample-ObjcUITests";
productName = "FSPagerViewExample-ObjcUITests";
productReference = F9C694491E40C6C1007084B6 /* FSPagerViewExample-ObjcUITests.xctest */;
productType = "com.apple.product-type.bundle.ui-testing";
};
F9EC37181E304A830022B6D6 /* FSPagerViewExample-Objc */ = {
isa = PBXNativeTarget;
buildConfigurationList = F9EC37301E304A830022B6D6 /* Build configuration list for PBXNativeTarget "FSPagerViewExample-Objc" */;
buildPhases = (
F9EC37151E304A830022B6D6 /* Sources */,
F9EC37161E304A830022B6D6 /* Frameworks */,
F9EC37171E304A830022B6D6 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = "FSPagerViewExample-Objc";
productName = "FSPageSliderExample-Objc";
productReference = F9EC37191E304A830022B6D6 /* FSPagerViewExample-Objc.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
F9EC37111E304A830022B6D6 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0820;
LastUpgradeCheck = 1030;
ORGANIZATIONNAME = "Wenchao Ding";
TargetAttributes = {
F9C694481E40C6C1007084B6 = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = HZF422TY46;
LastSwiftMigration = 0900;
ProvisioningStyle = Automatic;
TestTargetID = F9EC37181E304A830022B6D6;
};
F9EC37181E304A830022B6D6 = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = HZF422TY46;
LastSwiftMigration = 0900;
ProvisioningStyle = Automatic;
};
};
};
buildConfigurationList = F9EC37141E304A830022B6D6 /* Build configuration list for PBXProject "FSPagerViewExample-Objc" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = F9EC37101E304A830022B6D6;
productRefGroup = F9EC371A1E304A830022B6D6 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
F9EC37181E304A830022B6D6 /* FSPagerViewExample-Objc */,
F9C694481E40C6C1007084B6 /* FSPagerViewExample-ObjcUITests */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
F9C694471E40C6C1007084B6 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
F9EC37171E304A830022B6D6 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
F908BC4A1E35AAE4002B2F51 /* 3.jpg in Resources */,
F908BC4C1E35AAE4002B2F51 /* 5.jpg in Resources */,
F9EC372C1E304A830022B6D6 /* LaunchScreen.storyboard in Resources */,
F908BC491E35AAE4002B2F51 /* 2.jpg in Resources */,
F9DF961D1E7F5B240010506C /* Assets.xcassets in Resources */,
F908BC4B1E35AAE4002B2F51 /* 4.jpg in Resources */,
F908BC4E1E35AAE4002B2F51 /* 7.jpg in Resources */,
F908BC4D1E35AAE4002B2F51 /* 6.jpg in Resources */,
F908BC411E35AAE4002B2F51 /* 1.jpg in Resources */,
F9EC37271E304A830022B6D6 /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
F9C694451E40C6C1007084B6 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
F9FF34A01E65B38C001E943F /* FSPagerViewLayoutAttributes.swift in Sources */,
F9C6944C1E40C6C1007084B6 /* FSPagerViewExample_ObjcUITests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
F9EC37151E304A830022B6D6 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
F9EC37241E304A830022B6D6 /* BasicExampleViewController.m in Sources */,
F9580B641E5D997200C5B267 /* FSPageControl.swift in Sources */,
F9580B681E5D997200C5B267 /* FSPageViewLayout.swift in Sources */,
F9EC37211E304A830022B6D6 /* AppDelegate.m in Sources */,
F9FF349F1E65B38C001E943F /* FSPagerViewLayoutAttributes.swift in Sources */,
F9580B651E5D997200C5B267 /* FSPagerCollectionView.swift in Sources */,
F9580B691E5D997200C5B267 /* FSPageViewTransformer.swift in Sources */,
F9F00A901E310FF600790735 /* TransformerExampleViewController.m in Sources */,
F9580B671E5D997200C5B267 /* FSPagerViewCell.swift in Sources */,
F93F5E141E319AE8006B7082 /* PageControlExampleViewController.m in Sources */,
F9EC371E1E304A830022B6D6 /* main.m in Sources */,
F9580B661E5D997200C5B267 /* FSPagerView.swift in Sources */,
F931E00A2158A1E4001B2A01 /* FSPagerViewObjcCompat.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
F9C6944F1E40C6C1007084B6 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = F9EC37181E304A830022B6D6 /* FSPagerViewExample-Objc */;
targetProxy = F9C6944E1E40C6C1007084B6 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
F9EC37251E304A830022B6D6 /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
F9EC37261E304A830022B6D6 /* Base */,
);
name = Main.storyboard;
sourceTree = "";
};
F9EC372A1E304A830022B6D6 /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
F9EC372B1E304A830022B6D6 /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
F9C694511E40C6C1007084B6 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
DEVELOPMENT_TEAM = HZF422TY46;
INFOPLIST_FILE = "FSPagerViewExample-ObjcUITests/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 10.2;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.wenchaod.FSPagerViewExample-ObjcUITests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 5.0;
TEST_TARGET_NAME = "FSPagerViewExample-Objc";
};
name = Debug;
};
F9C694521E40C6C1007084B6 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
DEVELOPMENT_TEAM = HZF422TY46;
INFOPLIST_FILE = "FSPagerViewExample-ObjcUITests/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 10.2;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.wenchaod.FSPagerViewExample-ObjcUITests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 5.0;
TEST_TARGET_NAME = "FSPagerViewExample-Objc";
};
name = Release;
};
F9EC372E1E304A830022B6D6 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
F9EC372F1E304A830022B6D6 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
F9EC37311E304A830022B6D6 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = HZF422TY46;
INFOPLIST_FILE = "$(SRCROOT)/FSPagerViewExample-Objc/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.wenchaod.FSPagerView-Objc";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
F9EC37321E304A830022B6D6 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = HZF422TY46;
INFOPLIST_FILE = "$(SRCROOT)/FSPagerViewExample-Objc/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.wenchaod.FSPagerView-Objc";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 5.0;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
F9C694501E40C6C1007084B6 /* Build configuration list for PBXNativeTarget "FSPagerViewExample-ObjcUITests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
F9C694511E40C6C1007084B6 /* Debug */,
F9C694521E40C6C1007084B6 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
F9EC37141E304A830022B6D6 /* Build configuration list for PBXProject "FSPagerViewExample-Objc" */ = {
isa = XCConfigurationList;
buildConfigurations = (
F9EC372E1E304A830022B6D6 /* Debug */,
F9EC372F1E304A830022B6D6 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
F9EC37301E304A830022B6D6 /* Build configuration list for PBXNativeTarget "FSPagerViewExample-Objc" */ = {
isa = XCConfigurationList;
buildConfigurations = (
F9EC37311E304A830022B6D6 /* Debug */,
F9EC37321E304A830022B6D6 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = F9EC37111E304A830022B6D6 /* Project object */;
}
================================================
FILE: FSPagerViewExample-Objc/FSPagerViewExample-Objc.xcodeproj/project.xcworkspace/contents.xcworkspacedata
================================================
================================================
FILE: FSPagerViewExample-Objc/FSPagerViewExample-ObjcUITests/FSPagerViewExample_ObjcUITests.swift
================================================
//
// FSPagerViewExample_ObjcUITests.swift
// FSPagerViewExample-ObjcUITests
//
// Created by Wenchao Ding on 31/01/2017.
// Copyright © 2017 Wenchao Ding. All rights reserved.
//
import XCTest
class FSPagerViewExample_ObjcUITests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
// In UI tests it is usually best to stop immediately when a failure occurs.
continueAfterFailure = false
// UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
XCUIApplication().launch()
// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
// Use recording to get started writing UI tests.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
}
================================================
FILE: FSPagerViewExample-Objc/FSPagerViewExample-ObjcUITests/Info.plist
================================================
CFBundleDevelopmentRegion
en
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIdentifier
$(PRODUCT_BUNDLE_IDENTIFIER)
CFBundleInfoDictionaryVersion
6.0
CFBundleName
$(PRODUCT_NAME)
CFBundlePackageType
BNDL
CFBundleShortVersionString
1.0
CFBundleVersion
1
================================================
FILE: FSPagerViewExamples.xcworkspace/contents.xcworkspacedata
================================================
================================================
FILE: LICENSE
================================================
Copyright (c) 2017 FSPagerView (https://github.com/WenchaoD/FSPagerView)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
================================================
FILE: Package.swift
================================================
// swift-tools-version:5.9
import PackageDescription
let package = Package(
name: "FSPagerView",
platforms: [
.iOS(.v12)
],
products: [
.library(name: "FSPagerView", targets: ["FSPagerView"]),
],
targets: [
.target(name: "FSPagerView", path: "Sources", exclude: ["FSPagerViewObjcCompat.h", "FSPagerViewObjcCompat.m"]),
],
swiftLanguageVersions: [.v5]
)
================================================
FILE: README-OBJECTIVE-C.md
================================================

[](#)
[](http://cocoadocs.org/docsets/FSPagerView)
[](http://cocoadocs.org/docsets/FSPagerView)
[](https://github.com/Carthage/Carthage)
[](https://swift.org/package-manager/)
|[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.
## Features
* ***Infinite*** scrolling.
* ***Automatic*** Sliding.
* Support ***Horizontal*** and ***Vertical*** paging.
* Fully customizable item, with predefined banner-style item.
* Fully customizable ***page control***.
* Rich build-in 3D transformers.
* ***Simple*** and ***Delightful*** api usage.
* Support **SWIFT** and **OBJECTIVE-C**.
## Demo1 Banner
| Banner |
|---|
| |
### automaticSlidingInterval
The time interval of automatic sliding. 0 means disabling automatic sliding. Default is 0.
**e.g.**
```objc
pagerView.automaticSlidingInterval = 3.0;
```
### isInfinite
A boolean value indicates whether the pager view has infinite number of items. Default is false.
**e.g.**
```objc
pagerView.isInfinite = YES;
```
### decelerationDistance
An unsigned integer value that determines the paging distance of the pager view, which indicates the number of passing items during the deceleration. When the value of this property is FSPagerViewAutomaticDistance, the actual 'distance' is automatically calculated according to the scrolling speed of the pager view. Default is 1.
**e.g.**
```objc
pagerView.decelerationDistance = 2
```
### itemSize
The item size of the pager view. When the value of this property is FSPagerViewAutomaticSize, the items fill the entire visible area of the pager view. Default is FSPagerViewAutomaticSize.
**e.g.**
```objc
pagerView.itemSize = CGSizeMake(200, 180);
```
### interitemSpacing
The spacing to use between items in the pager view. Default is 0.
**e.g.**
```objc
pagerView.interitemSpacing = 10;
```
## Demo2 - Transformers
|Cross Fading|
|---|
|  |
```objc
pagerView.transformer = [[FSPagerViewTransformer alloc] initWithType:FSPagerViewTransformerTypeCrossFading];
```
---
|Zoom Out|
|---|
|  |
```objc
pagerView.transformer = [[FSPagerViewTransformer alloc] initWithType:FSPagerViewTransformerTypeZoomOut];
```
---
|Depth|
|---|
|  |
```objc
pagerView.transformer = [[FSPagerViewTransformer alloc] initWithType:FSPagerViewTransformerTypeDepth];
```
---
|Linear|
|---|
|  |
```objc
pagerView.transformer = [[FSPagerViewTransformer alloc] initWithType:FSPagerViewTransformerTypeLinear];
```
---
|Overlap|
|---|
|  |
```objc
pagerView.transformer = [[FSPagerViewTransformer alloc] initWithType:FSPagerViewTransformerTypeOverlap];
```
---
|Ferris Wheel|
|------|
|  |
```objc
pagerView.transformer = [[FSPagerViewTransformer alloc] initWithType:FSPagerViewTransformerTypeFerrisWheel];
```
---
|Inverted Ferris Wheel|
|------|
|  |
```objc
pagerView.transformer = [[FSPagerViewTransformer alloc] initWithType:FSPagerViewTransformerTypeInvertedFerrisWheel];
```
---
|Cover Flow|
|------|
|  |
```objc
pagerView.transformer = [[FSPagerViewTransformer alloc] initWithType:FSPagerViewTransformerTypeCoverFlow];
```
---
|Cubic|
|------|
|  |
```objc
pagerView.transformer = [[FSPagerViewTransformer alloc] initWithType:FSPagerViewTransformerTypeCubic];
```
---
> Customize your own transformer by subclassing`FSPagerViewTransformer.`
## Demo3 Page Control
|Page Control|
|---|
|
|
### numberOfPages
The number of page indicators of the page control. Default is 0.
**e.g.**
```objc
pageControl.numberOfPages = 5;
```
### currentPage
The current page, highlighted by the page control. Default is 0.
**e.g.**
```objc
pageControl.currentPage = 1;
```
### contentHorizontalAlignment
The horizontal alignment of content within the control’s bounds. Default is center.
**e.g.**
```objc
pageControl.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
```
### setStrokeColor:forState:
Sets the stroke color for page indicators to use for the specified state. (selected/normal).
**e.g.**
```objc
[pageControl setStrokeColor:[UIColor greenColor] forState:UIControlStateNormal];
[pageControl setStrokeColor:[UIColor yellowColor] forState:UIControlStateSelected];
```
### setFillColor:forState:
Sets the fill color for page indicators to use for the specified state. (selected/normal).
**e.g.**
```objc
[pageControl setFillColor:[UIColor grayColor] forState:UIControlStateNormal];
[pageControl setFillColor:[UIColor whiteColor] forState:UIControlStateSelected];
```
### setImage:forState:
Sets the image for page indicators to use for the specified state. (selected/normal).
**e.g.**
```objc
[pageControl setImage:[UIImage imageNamed:@"image1"] forState:UIControlStateNormal];
[pageControl setImage:[UIImage imageNamed:@"image2"] forState:UIControlStateSelected];
```
### setPath:forState:
Sets the path for page indicators to use for the specified state. (selected/normal).
**e.g.**
```objc
[pageControl setPath:[UIBezierPath bezierPathWithRect:CGRectMake(0, 0, 8, 8)] forState:UIControlStateNormal];
[pageControl setPath: [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, 8, 8)] forState:UIControlStateSelected];
```
## Installation
* Manually
* Cocoapods
* Carthage
### Manually
1. ***[Download](#)*** the source code.
2. Extract the zip file, simply drag folder ***Sources*** into your project.
3. Make sure ***Copy items if needed*** is checked.
### Cocoapods
```ruby
use_frameworks!
target '' do
pod 'FSPagerView'
end
```
### Carthage
```ruby
github "WenchaoD/FSPagerView"
```
## Tutorial
* [Getting started](#getting_started)
* [Implement FSPagerViewDataSource](#implement_fspagerviewdatasource)
* [Implement FSPagerViewDelegate](#implement_fspagerviewdelegate)
### 1. Getting started
* Getting started with code
```objc
// Create a pager view
FSPagerView *pagerView = [[FSPagerView alloc] initWithFrame:frame1];
pagerView.dataSource = self;
pagerView.delegate = self;
[pagerView registerClass:[FSPagerViewCell class] forCellWithReuseIdentifier:@"cell"];
[self.view addSubview:pagerView];
// Create a page control
FSPageControl *pageControl = [[FSPageControl alloc] initWithFrame:frame2];
[self.view addSubview:pageControl];
```
* Getting started with Interface Builder
1、Simply drag **UIView** instance into your View Controller, Change the `Custom Class` to `FSPagerView`. (Or `FSPageControl`)
2、Link the `dataSource` and `delegate` property of **FSPagerView** to your View Controller.
3、Register a cell class.
```objc
- (void)viewDidLoad
{
[super viewDidLoad];
[self.pagerView registerClass:[FSPagerViewCell class] forCellWithReuseIdentifier:@"cell"];
}
```
### 2. Implement FSPagerViewDataSource
```objc
- (NSInteger)numberOfItemsInpagerView:(FSPagerView *)pagerView
{
return numberOfItems;
}
- (FSPagerViewCell *)pagerView:(FSPagerView *)pagerView cellForItemAtIndex:(NSInteger)index
{
FSPagerViewCell *cell = [pagerView dequeueReusableCellWithReuseIdentifier:@"cell" atIndex:index];
cell.imageView.image = ...;
cell.textLabel.text = ...;
return cell;
}
```
### 3. Implement FSPagerViewDelegate
```objc
- (BOOL)pagerView:(FSPagerView *)pagerView shouldHighlightItemAtIndex:(NSInteger)index;
```
> Asks the delegate if the item should be highlighted during tracking.
---
```objc
- (void)pagerView:(FSPagerView *)pagerView didHighlightItemAtIndex:(NSInteger)index;
```
> Tells the delegate that the item at the specified index was highlighted.
---
```objc
- (BOOL)pagerView:(FSPagerView *)pagerView shouldSelectItemAtIndex:(NSInteger)index;
```
> Asks the delegate if the specified item should be selected.
---
```objc
- (void)pagerView:(FSPagerView *)pagerView didSelectItemAtIndex:(NSInteger)index;
```
> Tells the delegate that the item at the specified index was selected.
---
```objc
- (void)pagerView:(FSPagerView *)pagerView willDisplayCell:(FSPagerViewCell *)cell forItemAtIndex:(NSInteger)index;
```
> Tells the delegate that the specified cell is about to be displayed in the pager view.
---
```objc
- (void)pagerView:(FSPagerView *)pagerView didEndDisplayingCell:(FSPagerViewCell *)cell forItemAtIndex:(NSInteger)index;
```
> Tells the delegate that the specified cell was removed from the pager view.
---
```objc
- (void)pagerViewWillBeginDragging:(FSPagerView *)pagerView;
```
> Tells the delegate when the pager view is about to start scrolling the content.
---
```objc
- (void)pagerViewWillEndDragging:(FSPagerView *) pagerView targetIndex:(NSInteger)index:
```
> Tells the delegate when the user finishes scrolling the content.
---
```objc
- (void)pagerViewDidScroll:(FSPagerView *)pagerView;
```
> Tells the delegate when the user scrolls the content view within the receiver.
---
```objc
- (void)pagerViewDidEndScrollAnimation:(FSPagerView *)pagerView;
```
> Tells the delegate when a scrolling animation in the pager view concludes.
---
```objc
- (void)pagerViewDidEndDecelerating:(FSPagerView *)pagerView;
```
> Tells the delegate that the pager view has ended decelerating the scrolling movement.
---
## Support this repo
* ***Star*** this repo
* Buy me a ***Coffee***. ☕️
|
|
---
## Author
* ***微博:[@WenchaoD](http://weibo.com/WenchaoD)***
* ***Twitter: [@WenchaoD](https://twitter.com/WenchaoD)***
* Other repos:
* ***[FSCalendar](https://github.com/WenchaoD/FSCalendar)***
---
# [Documentation](http://cocoadocs.org/docsets/FSPagerView)
================================================
FILE: README.md
================================================

[](#)
[](http://cocoadocs.org/docsets/FSPagerView)
[](http://cocoadocs.org/docsets/FSPagerView)
[](https://github.com/Carthage/Carthage)
[](https://swift.org/package-manager/)
|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.
## Features
* ***Infinite*** scrolling.
* ***Automatic*** Sliding.
* ***Horizontal*** and ***Vertical*** paging.
* Fully customizable item, with predefined banner-style item.
* Fully customizable ***page control***.
* Rich build-in 3D transformers.
* ***Simple*** and ***Delightful*** api usage.
* Support **SWIFT** and **OBJECTIVE-C**.
## Demos
* [Demo1 - Banner](#banner)
* [Demo2 - Transformer](#transformer)
* [Demo3 - Page Control](#page_control)
### Demo1 - Banner
| Banner |
|---|
| |
### automaticSlidingInterval
The time interval of automatic sliding. 0 means disabling automatic sliding. Default is 0.
**e.g.**
```swift
pagerView.automaticSlidingInterval = 3.0
```
### isInfinite
A boolean value indicates whether the pager view has infinite number of items. Default is false.
**e.g.**
```swift
pagerView.isInfinite = true
```
### decelerationDistance
An unsigned integer value that determines the paging 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.
**e.g.**
```swift
pagerView.decelerationDistance = 2
```
### itemSize
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.
**e.g.**
```swift
pagerView.itemSize = CGSize(width: 200, height: 180)
```
### interitemSpacing
The spacing to use between items in the pager view. Default is 0.
**e.g.**
```swift
pagerView.interitemSpacing = 10
```
## Demo2 - Transformers
|Cross Fading|
|---|
|  |
```swift
pagerView.transformer = FSPagerViewTransformer(type: .crossFading)
```
---
|Zoom Out|
|---|
|  |
```swift
pagerView.transformer = FSPagerViewTransformer(type: .zoomOut)
```
---
|Depth|
|---|
|  |
```swift
pagerView.transformer = FSPagerViewTransformer(type: .depth)
```
---
|Linear|
|---|
|  |
```swift
pagerView.transformer = FSPagerViewTransformer(type: .linear)
```
---
|Overlap|
|---|
|  |
```swift
pagerView.transformer = FSPagerViewTransformer(type: .overlap)
```
---
|Ferris Wheel|
|------|
|  |
```swift
pagerView.transformer = FSPagerViewTransformer(type: .ferrisWheel)
```
---
|Inverted Ferris Wheel|
|------|
|  |
```swift
pagerView.transformer = FSPagerViewTransformer(type: .invertedFerrisWheel)
```
---
|Cover Flow|
|------|
|  |
```swift
pagerView.transformer = FSPagerViewTransformer(type: .coverFlow)
```
---
|Cubic|
|------|
|  |
```swift
pagerView.transformer = FSPagerViewTransformer(type: .cubic)
```
---
> Customize your own transformer by subclassing`FSPagerViewTransformer.`
## Demo3 Page Control
|Page Control|
|---|
|
|
### numberOfPages
The number of page indicators of the page control. Default is 0.
**e.g.**
```swift
pageControl.numberOfPages = 5
```
### currentPage
The current page, highlighted by the page control. Default is 0.
**e.g.**
```swift
pageControl.currentPage = 1
```
### contentHorizontalAlignment
The horizontal alignment of content within the control’s bounds. Default is center.
**e.g.**
```swift
pageControl.contentHorizontalAlignment = .right
```
### setStrokeColor:forState:
Sets the stroke color for page indicators to use for the specified state. (selected/normal).
**e.g.**
```swift
pageControl.setStrokeColor(.green, for: .normal)
pageControl.setStrokeColor(.yellow, for: .selected)
```
### setFillColor:forState:
Sets the fill color for page indicators to use for the specified state. (selected/normal).
**e.g.**
```swift
pageControl.setFillColor(.gray, for: .normal)
pageControl.setFillColor(.white, for: .selected)
```
### setImage:forState:
Sets the image for page indicators to use for the specified state. (selected/normal).
**e.g.**
```swift
pageControl.setImage(UIImage(named:"image1"), for: .normal)
pageControl.setImage(UIImage(named:"image2"), for: .selected)
```
### setPath:forState:
Sets the path for page indicators to use for the specified state. (selected/normal).
**e.g.**
```swift
pageControl.setPath(UIBezierPath(rect: CGRect(x: 0, y: 0, width: 8, height: 8)), for: .normal)
pageControl.setPath(UIBezierPath(ovalIn: CGRect(x: 0, y: 0, width: 8, height: 8)), for: .selected)
```
## Installation
* Manually
* Cocoapods
* Carthage
### Manually
1. ***[Download](#)*** the source code.
2. Extract the zip file, simply drag folder ***Sources*** into your project.
3. Make sure ***Copy items if needed*** is checked.
### Cocoapods
```ruby
use_frameworks!
target '' do
pod 'FSPagerView'
end
```
### Carthage
```ruby
github "WenchaoD/FSPagerView"
```
## Tutorial
* [Getting started](#getting_started)
* [Implement FSPagerViewDataSource](#implement_fspagerviewdatasource)
* [Implement FSPagerViewDelegate](#implement_fspagerviewdelegate)
### 1. Getting started
* Getting started with code
```swift
// Create a pager view
let pagerView = FSPagerView(frame: frame1)
pagerView.dataSource = self
pagerView.delegate = self
pagerView.register(FSPagerViewCell.self, forCellWithReuseIdentifier: "cell")
self.view.addSubview(pagerView)
// Create a page control
let pageControl = FSPageControl(frame: frame2)
self.view.addSubview(pageControl)
```
* Getting started with Interface Builder
1、Simply drag **UIView** instance into your View Controller, Change the `Custom Class` to `FSPagerView`. (Or `FSPageControl`)
2、Link the `dataSource` and `delegate` property of **FSPagerView** to your View Controller.
3、Register a cell class.
```swift
@IBOutlet weak var pagerView: FSPagerView! {
didSet {
self.pagerView.register(FSPagerViewCell.self, forCellWithReuseIdentifier: "cell")
}
}
```
### 2. Implement FSPagerViewDataSource
```swift
public func numberOfItems(in pagerView: FSPagerView) -> Int {
return numberOfItems
}
public func pagerView(_ pagerView: FSPagerView, cellForItemAt index: Int) -> FSPagerViewCell {
let cell = pagerView.dequeueReusableCell(withReuseIdentifier: "cell", at: index)
cell.imageView?.image = ...
cell.textLabel?.text = ...
return cell
}
```
### 3. Implement FSPagerViewDelegate
```swift
func pagerView(_ pagerView: FSPagerView, shouldHighlightItemAt index: Int) -> Bool
```
> Asks the delegate if the item should be highlighted during tracking.
---
```swift
func pagerView(_ pagerView: FSPagerView, didHighlightItemAt index: Int)
```
> Tells the delegate that the item at the specified index was highlighted.
---
```swift
func pagerView(_ pagerView: FSPagerView, shouldSelectItemAt index: Int) -> Bool
```
> Asks the delegate if the specified item should be selected.
---
```swift
func pagerView(_ pagerView: FSPagerView, didSelectItemAt index: Int)
```
> Tells the delegate that the item at the specified index was selected.
---
```swift
func pagerView(_ pagerView: FSPagerView, willDisplay cell: FSPagerViewCell, forItemAt index: Int)
```
> Tells the delegate that the specified cell is about to be displayed in the pager view.
---
```swift
func pagerView(_ pagerView: FSPagerView, didEndDisplaying cell: FSPagerViewCell, forItemAt index: Int)
```
> Tells the delegate that the specified cell was removed from the pager view.
---
```swift
func pagerViewWillBeginDragging(_ pagerView: FSPagerView)
```
> Tells the delegate when the pager view is about to start scrolling the content.
---
```swift
func pagerViewWillEndDragging(_ pagerView: FSPagerView, targetIndex: Int)
```
> Tells the delegate when the user finishes scrolling the content.
---
```swift
func pagerViewDidScroll(_ pagerView: FSPagerView)
```
> Tells the delegate when the user scrolls the content view within the receiver.
---
```swift
func pagerViewDidEndScrollAnimation(_ pagerView: FSPagerView)
```
> Tells the delegate when a scrolling animation in the pager view concludes.
---
```swift
func pagerViewDidEndDecelerating(_ pagerView: FSPagerView)
```
> Tells the delegate that the pager view has ended decelerating the scrolling movement.
---
## Support this repo
* ***Star*** this repo
* Buy me a Coffee. ☕️
|
|
---
## Author
* ***微博:[@WenchaoD](http://weibo.com/WenchaoD)***
* ***Twitter: [@WenchaoD](https://twitter.com/WenchaoD)***
* Other repos:
* [***FSCalendar***](https://github.com/WenchaoD)
---
# [Documentation](http://cocoadocs.org/docsets/FSPagerView)
================================================
FILE: Resources/Assets.xcassets/AppIcon.appiconset/Contents.json
================================================
{
"images" : [
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "Icon-40.png",
"scale" : "2x"
},
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "Icon-60.png",
"scale" : "3x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-Small@2x-1.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-Small@3x.png",
"scale" : "3x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-40@2x.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-40@3x.png",
"scale" : "3x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-60@2x.png",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-60@3x.png",
"scale" : "3x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "Icon-20.png",
"scale" : "1x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "Icon-41.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "Icon-Small.png",
"scale" : "1x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "Icon-Small@2x.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "Icon-42.png",
"scale" : "1x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "Icon-40@2x-1.png",
"scale" : "2x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "Icon-76.png",
"scale" : "1x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "Icon-76@2x.png",
"scale" : "2x"
},
{
"size" : "83.5x83.5",
"idiom" : "ipad",
"filename" : "Icon-167.png",
"scale" : "2x"
},
{
"size" : "1024x1024",
"idiom" : "ios-marketing",
"filename" : "icon-1024.png",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"pre-rendered" : true
}
}
================================================
FILE: Resources/Assets.xcassets/Contents.json
================================================
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Resources/Assets.xcassets/icon_cat.imageset/Contents.json
================================================
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "icon_cat@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Resources/Assets.xcassets/icon_footprint.imageset/Contents.json
================================================
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "icon_footprint@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
================================================
FILE: Sources/FSPageControl.swift
================================================
//
// FSPageControl.swift
// FSPagerView
//
// Created by Wenchao Ding on 17/12/2016.
// Copyright © 2016 Wenchao Ding. All rights reserved.
//
import UIKit
@IBDesignable
open class FSPageControl: UIControl {
/// The number of page indicators of the page control. Default is 0.
@IBInspectable
open var numberOfPages: Int = 0 {
didSet {
self.setNeedsCreateIndicators()
}
}
/// The current page, highlighted by the page control. Default is 0.
@IBInspectable
open var currentPage: Int = 0 {
didSet {
self.setNeedsUpdateIndicators()
}
}
/// The spacing to use of page indicators in the page control.
@IBInspectable
open var itemSpacing: CGFloat = 6 {
didSet {
self.setNeedsUpdateIndicators()
}
}
/// The spacing to use between page indicators in the page control.
@IBInspectable
open var interitemSpacing: CGFloat = 6 {
didSet {
self.setNeedsLayout()
}
}
/// The distance that the page indicators is inset from the enclosing page control.
@IBInspectable
open var contentInsets: UIEdgeInsets = .zero {
didSet {
self.setNeedsLayout()
}
}
/// The horizontal alignment of content within the control’s bounds. Default is center.
open override var contentHorizontalAlignment: UIControl.ContentHorizontalAlignment {
didSet {
self.setNeedsLayout()
}
}
/// Hide the indicator if there is only one page. default is NO
@IBInspectable
open var hidesForSinglePage: Bool = false {
didSet {
self.setNeedsUpdateIndicators()
}
}
internal var strokeColors: [UIControl.State: UIColor] = [:]
internal var fillColors: [UIControl.State: UIColor] = [:]
internal var paths: [UIControl.State: UIBezierPath] = [:]
internal var images: [UIControl.State: UIImage] = [:]
internal var alphas: [UIControl.State: CGFloat] = [:]
internal var transforms: [UIControl.State: CGAffineTransform] = [:]
fileprivate weak var contentView: UIView!
fileprivate var needsUpdateIndicators = false
fileprivate var needsCreateIndicators = false
fileprivate var indicatorLayers = [CAShapeLayer]()
public override init(frame: CGRect) {
super.init(frame: frame)
commonInit()
}
public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
commonInit()
}
open override func layoutSubviews() {
super.layoutSubviews()
self.contentView.frame = {
let x = self.contentInsets.left
let y = self.contentInsets.top
let width = self.frame.width - self.contentInsets.left - self.contentInsets.right
let height = self.frame.height - self.contentInsets.top - self.contentInsets.bottom
let frame = CGRect(x: x, y: y, width: width, height: height)
return frame
}()
}
open override func layoutSublayers(of layer: CALayer) {
super.layoutSublayers(of: layer)
let diameter = self.itemSpacing
let spacing = self.interitemSpacing
var x: CGFloat = {
switch self.contentHorizontalAlignment {
case .left, .leading:
return 0
case .center, .fill:
let midX = self.contentView.bounds.midX
let amplitude = CGFloat(self.numberOfPages/2) * diameter + spacing*CGFloat((self.numberOfPages-1)/2)
return midX - amplitude
case .right, .trailing:
let contentWidth = diameter*CGFloat(self.numberOfPages) + CGFloat(self.numberOfPages-1)*spacing
return contentView.frame.width - contentWidth
default:
return 0
}
}()
for (index,value) in self.indicatorLayers.enumerated() {
let state: UIControl.State = (index == self.currentPage) ? .selected : .normal
let image = self.images[state]
let size = image?.size ?? CGSize(width: diameter, height: diameter)
let origin = CGPoint(x: x - (size.width-diameter)*0.5, y: self.contentView.bounds.midY-size.height*0.5)
value.frame = CGRect(origin: origin, size: size)
x = x + spacing + diameter
}
}
/// 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: UIControl.State) {
guard self.strokeColors[state] != strokeColor else {
return
}
self.strokeColors[state] = strokeColor
self.setNeedsUpdateIndicators()
}
/// 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: UIControl.State) {
guard self.fillColors[state] != fillColor else {
return
}
self.fillColors[state] = fillColor
self.setNeedsUpdateIndicators()
}
/// 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: UIControl.State) {
guard self.images[state] != image else {
return
}
self.images[state] = image
self.setNeedsUpdateIndicators()
}
@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: UIControl.State) {
guard self.alphas[state] != alpha else {
return
}
self.alphas[state] = alpha
self.setNeedsUpdateIndicators()
}
/// 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: UIControl.State) {
guard self.paths[state] != path else {
return
}
self.paths[state] = path
self.setNeedsUpdateIndicators()
}
// MARK: - Private functions
fileprivate func commonInit() {
// Content View
let view = UIView(frame: .zero)
view.backgroundColor = UIColor.clear
self.addSubview(view)
self.contentView = view
self.isUserInteractionEnabled = false
}
fileprivate func setNeedsUpdateIndicators() {
self.needsUpdateIndicators = true
self.setNeedsLayout()
DispatchQueue.main.async {
self.updateIndicatorsIfNecessary()
}
}
fileprivate func updateIndicatorsIfNecessary() {
guard self.needsUpdateIndicators else {
return
}
guard self.indicatorLayers.count > 0 else {
return
}
self.needsUpdateIndicators = false
self.contentView.isHidden = self.hidesForSinglePage && self.numberOfPages <= 1
if !self.contentView.isHidden {
self.indicatorLayers.forEach { (layer) in
layer.isHidden = false
self.updateIndicatorAttributes(for: layer)
}
}
}
fileprivate func updateIndicatorAttributes(for layer: CAShapeLayer) {
let index = self.indicatorLayers.firstIndex(of: layer)
let state: UIControl.State = index == self.currentPage ? .selected : .normal
if let image = self.images[state] {
layer.strokeColor = nil
layer.fillColor = nil
layer.path = nil
layer.contents = image.cgImage
} else {
layer.contents = nil
let strokeColor = self.strokeColors[state]
let fillColor = self.fillColors[state]
if strokeColor == nil && fillColor == nil {
layer.fillColor = (state == .selected ? UIColor.white : UIColor.gray).cgColor
layer.strokeColor = nil
} else {
layer.strokeColor = strokeColor?.cgColor
layer.fillColor = fillColor?.cgColor
}
layer.path = self.paths[state]?.cgPath ?? UIBezierPath(ovalIn: CGRect(x: 0, y: 0, width: self.itemSpacing, height: self.itemSpacing)).cgPath
}
if let transform = self.transforms[state] {
layer.transform = CATransform3DMakeAffineTransform(transform)
}
layer.opacity = Float(self.alphas[state] ?? 1.0)
}
fileprivate func setNeedsCreateIndicators() {
self.needsCreateIndicators = true
DispatchQueue.main.async {
self.createIndicatorsIfNecessary()
}
}
fileprivate func createIndicatorsIfNecessary() {
guard self.needsCreateIndicators else {
return
}
self.needsCreateIndicators = false
CATransaction.begin()
CATransaction.setDisableActions(true)
if self.currentPage >= self.numberOfPages {
self.currentPage = self.numberOfPages - 1
}
self.indicatorLayers.forEach { (layer) in
layer.removeFromSuperlayer()
}
self.indicatorLayers.removeAll()
for _ in 0.. Bool {
return true
}
override open func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
var layoutAttributes = [UICollectionViewLayoutAttributes]()
guard self.itemSpacing > 0, !rect.isEmpty else {
return layoutAttributes
}
let rect = rect.intersection(CGRect(origin: .zero, size: self.contentSize))
guard !rect.isEmpty else {
return layoutAttributes
}
// Calculate start position and index of certain rects
let numberOfItemsBefore = self.scrollDirection == .horizontal ? max(Int((rect.minX-self.leadingSpacing)/self.itemSpacing),0) : max(Int((rect.minY-self.leadingSpacing)/self.itemSpacing),0)
let startPosition = self.leadingSpacing + CGFloat(numberOfItemsBefore)*self.itemSpacing
let startIndex = numberOfItemsBefore
// Create layout attributes
var itemIndex = startIndex
var origin = startPosition
let maxPosition = self.scrollDirection == .horizontal ? min(rect.maxX,self.contentSize.width-self.actualItemSize.width-self.leadingSpacing) : min(rect.maxY,self.contentSize.height-self.actualItemSize.height-self.leadingSpacing)
// https://stackoverflow.com/a/10335601/2398107
while origin-maxPosition <= max(CGFloat(100.0) * .ulpOfOne * abs(origin+maxPosition), .leastNonzeroMagnitude) {
let indexPath = IndexPath(item: itemIndex%self.numberOfItems, section: itemIndex/self.numberOfItems)
let attributes = self.layoutAttributesForItem(at: indexPath) as! FSPagerViewLayoutAttributes
self.applyTransform(to: attributes, with: self.pagerView?.transformer)
layoutAttributes.append(attributes)
itemIndex += 1
origin += self.itemSpacing
}
return layoutAttributes
}
override open func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
let attributes = FSPagerViewLayoutAttributes(forCellWith: indexPath)
attributes.indexPath = indexPath
let frame = self.frame(for: indexPath)
let center = CGPoint(x: frame.midX, y: frame.midY)
attributes.center = center
attributes.size = self.actualItemSize
return attributes
}
override open func targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint, withScrollingVelocity velocity: CGPoint) -> CGPoint {
guard let collectionView = self.collectionView, let pagerView = self.pagerView else {
return proposedContentOffset
}
var proposedContentOffset = proposedContentOffset
func calculateTargetOffset(by proposedOffset: CGFloat, boundedOffset: CGFloat) -> CGFloat {
var targetOffset: CGFloat
if pagerView.decelerationDistance == FSPagerView.automaticDistance {
if abs(velocity.x) >= 0.3 {
let vector: CGFloat = velocity.x >= 0 ? 1.0 : -1.0
targetOffset = round(proposedOffset/self.itemSpacing+0.35*vector) * self.itemSpacing // Ceil by 0.15, rather than 0.5
} else {
targetOffset = round(proposedOffset/self.itemSpacing) * self.itemSpacing
}
} else {
let extraDistance = max(pagerView.decelerationDistance-1, 0)
switch velocity.x {
case 0.3 ... CGFloat.greatestFiniteMagnitude:
targetOffset = ceil(collectionView.contentOffset.x/self.itemSpacing+CGFloat(extraDistance)) * self.itemSpacing
case -CGFloat.greatestFiniteMagnitude ... -0.3:
targetOffset = floor(collectionView.contentOffset.x/self.itemSpacing-CGFloat(extraDistance)) * self.itemSpacing
default:
targetOffset = round(proposedOffset/self.itemSpacing) * self.itemSpacing
}
}
targetOffset = max(0, targetOffset)
targetOffset = min(boundedOffset, targetOffset)
return targetOffset
}
let proposedContentOffsetX: CGFloat = {
if self.scrollDirection == .vertical {
return proposedContentOffset.x
}
let boundedOffset = collectionView.contentSize.width-self.itemSpacing
return calculateTargetOffset(by: proposedContentOffset.x, boundedOffset: boundedOffset)
}()
let proposedContentOffsetY: CGFloat = {
if self.scrollDirection == .horizontal {
return proposedContentOffset.y
}
let boundedOffset = collectionView.contentSize.height-self.itemSpacing
return calculateTargetOffset(by: proposedContentOffset.y, boundedOffset: boundedOffset)
}()
proposedContentOffset = CGPoint(x: proposedContentOffsetX, y: proposedContentOffsetY)
return proposedContentOffset
}
// MARK:- Internal functions
internal func forceInvalidate() {
self.needsReprepare = true
self.invalidateLayout()
}
internal func contentOffset(for indexPath: IndexPath) -> CGPoint {
let origin = self.frame(for: indexPath).origin
guard let collectionView = self.collectionView else {
return origin
}
let contentOffsetX: CGFloat = {
if self.scrollDirection == .vertical {
return 0
}
let contentOffsetX = origin.x - (collectionView.frame.width*0.5-self.actualItemSize.width*0.5)
return contentOffsetX
}()
let contentOffsetY: CGFloat = {
if self.scrollDirection == .horizontal {
return 0
}
let contentOffsetY = origin.y - (collectionView.frame.height*0.5-self.actualItemSize.height*0.5)
return contentOffsetY
}()
let contentOffset = CGPoint(x: contentOffsetX, y: contentOffsetY)
return contentOffset
}
internal func frame(for indexPath: IndexPath) -> CGRect {
let numberOfItems = self.numberOfItems*indexPath.section + indexPath.item
let originX: CGFloat = {
if self.scrollDirection == .vertical {
return (self.collectionView!.frame.width-self.actualItemSize.width)*0.5
}
return self.leadingSpacing + CGFloat(numberOfItems)*self.itemSpacing
}()
let originY: CGFloat = {
if self.scrollDirection == .horizontal {
return (self.collectionView!.frame.height-self.actualItemSize.height)*0.5
}
return self.leadingSpacing + CGFloat(numberOfItems)*self.itemSpacing
}()
let origin = CGPoint(x: originX, y: originY)
let frame = CGRect(origin: origin, size: self.actualItemSize)
return frame
}
// MARK:- Notification
@objc
fileprivate func didReceiveNotification(notification: Notification) {
if self.pagerView?.itemSize == .zero {
self.adjustCollectionViewBounds()
}
}
// MARK:- Private functions
fileprivate func commonInit() {
#if !os(tvOS)
NotificationCenter.default.addObserver(self, selector: #selector(didReceiveNotification(notification:)), name: UIDevice.orientationDidChangeNotification, object: nil)
#endif
}
fileprivate func adjustCollectionViewBounds() {
guard let collectionView = self.collectionView, let pagerView = self.pagerView else {
return
}
let currentIndex = pagerView.currentIndex
let newIndexPath = IndexPath(item: currentIndex, section: pagerView.isInfinite ? self.numberOfSections/2 : 0)
let contentOffset = self.contentOffset(for: newIndexPath)
let newBounds = CGRect(origin: contentOffset, size: collectionView.frame.size)
collectionView.bounds = newBounds
}
fileprivate func applyTransform(to attributes: FSPagerViewLayoutAttributes, with transformer: FSPagerViewTransformer?) {
guard let collectionView = self.collectionView else {
return
}
guard let transformer = transformer else {
return
}
switch self.scrollDirection {
case .horizontal:
let ruler = collectionView.bounds.midX
attributes.position = (attributes.center.x-ruler)/self.itemSpacing
case .vertical:
let ruler = collectionView.bounds.midY
attributes.position = (attributes.center.y-ruler)/self.itemSpacing
}
attributes.zIndex = Int(self.numberOfItems)-Int(attributes.position)
transformer.applyTransform(to: attributes)
}
}
================================================
FILE: Sources/FSPageViewTransformer.swift
================================================
//
// FSPagerViewTransformer.swift
// FSPagerView
//
// Created by Wenchao Ding on 05/01/2017.
// Copyright © 2017 Wenchao Ding. All rights reserved.
//
import UIKit
@objc
public enum FSPagerViewTransformerType: Int {
case crossFading
case zoomOut
case depth
case overlap
case linear
case coverFlow
case ferrisWheel
case invertedFerrisWheel
case cubic
}
open class FSPagerViewTransformer: NSObject {
open internal(set) weak var pagerView: FSPagerView?
open internal(set) var type: FSPagerViewTransformerType
@objc open var minimumScale: CGFloat = 0.65
@objc open var minimumAlpha: CGFloat = 0.6
@objc
public init(type: FSPagerViewTransformerType) {
self.type = type
switch type {
case .zoomOut:
self.minimumScale = 0.85
case .depth:
self.minimumScale = 0.5
default:
break
}
}
// Apply transform to attributes - zIndex: Int, frame: CGRect, alpha: CGFloat, transform: CGAffineTransform or transform3D: CATransform3D.
open func applyTransform(to attributes: FSPagerViewLayoutAttributes) {
guard let pagerView = self.pagerView else {
return
}
let position = attributes.position
let scrollDirection = pagerView.scrollDirection
let itemSpacing = (scrollDirection == .horizontal ? attributes.bounds.width : attributes.bounds.height) + self.proposedInteritemSpacing()
switch self.type {
case .crossFading:
var zIndex = 0
var alpha: CGFloat = 0
var transform = CGAffineTransform.identity
switch scrollDirection {
case .horizontal:
transform.tx = -itemSpacing * position
case .vertical:
transform.ty = -itemSpacing * position
}
if (abs(position) < 1) { // [-1,1]
// Use the default slide transition when moving to the left page
alpha = 1 - abs(position)
zIndex = 1
} else { // (1,+Infinity]
// This page is way off-screen to the right.
alpha = 0
zIndex = Int.min
}
attributes.alpha = alpha
attributes.transform = transform
attributes.zIndex = zIndex
case .zoomOut:
var alpha: CGFloat = 0
var transform = CGAffineTransform.identity
switch position {
case -CGFloat.greatestFiniteMagnitude ..< -1 : // [-Infinity,-1)
// This page is way off-screen to the left.
alpha = 0
case -1 ... 1 : // [-1,1]
// Modify the default slide transition to shrink the page as well
let scaleFactor = max(self.minimumScale, 1 - abs(position))
transform.a = scaleFactor
transform.d = scaleFactor
switch scrollDirection {
case .horizontal:
let vertMargin = attributes.bounds.height * (1 - scaleFactor) / 2;
let horzMargin = itemSpacing * (1 - scaleFactor) / 2;
transform.tx = position < 0 ? (horzMargin - vertMargin*2) : (-horzMargin + vertMargin*2)
case .vertical:
let horzMargin = attributes.bounds.width * (1 - scaleFactor) / 2;
let vertMargin = itemSpacing * (1 - scaleFactor) / 2;
transform.ty = position < 0 ? (vertMargin - horzMargin*2) : (-vertMargin + horzMargin*2)
}
// Fade the page relative to its size.
alpha = self.minimumAlpha + (scaleFactor-self.minimumScale)/(1-self.minimumScale)*(1-self.minimumAlpha)
case 1 ... CGFloat.greatestFiniteMagnitude : // (1,+Infinity]
// This page is way off-screen to the right.
alpha = 0
default:
break
}
attributes.alpha = alpha
attributes.transform = transform
case .depth:
var transform = CGAffineTransform.identity
var zIndex = 0
var alpha: CGFloat = 0.0
switch position {
case -CGFloat.greatestFiniteMagnitude ..< -1: // [-Infinity,-1)
// This page is way off-screen to the left.
alpha = 0
zIndex = 0
case -1 ... 0: // [-1,0]
// Use the default slide transition when moving to the left page
alpha = 1
transform.tx = 0
transform.a = 1
transform.d = 1
zIndex = 1
case 0 ..< 1: // (0,1)
// Fade the page out.
alpha = CGFloat(1.0) - position
// Counteract the default slide transition
switch scrollDirection {
case .horizontal:
transform.tx = itemSpacing * -position
case .vertical:
transform.ty = itemSpacing * -position
}
// Scale the page down (between minimumScale and 1)
let scaleFactor = self.minimumScale
+ (1.0 - self.minimumScale) * (1.0 - abs(position));
transform.a = scaleFactor
transform.d = scaleFactor
zIndex = 0
case 1 ... CGFloat.greatestFiniteMagnitude: // [1,+Infinity)
// This page is way off-screen to the right.
alpha = 0
zIndex = 0
default:
break
}
attributes.alpha = alpha
attributes.transform = transform
attributes.zIndex = zIndex
case .overlap,.linear:
guard scrollDirection == .horizontal else {
// This type doesn't support vertical mode
return
}
let scale = max(1 - (1-self.minimumScale) * abs(position), self.minimumScale)
let transform = CGAffineTransform(scaleX: scale, y: scale)
attributes.transform = transform
let alpha = (self.minimumAlpha + (1-abs(position))*(1-self.minimumAlpha))
attributes.alpha = alpha
let zIndex = (1-abs(position)) * 10
attributes.zIndex = Int(zIndex)
case .coverFlow:
guard scrollDirection == .horizontal else {
// This type doesn't support vertical mode
return
}
let position = min(max(-position,-1) ,1)
let rotation = sin(position*(.pi)*0.5)*(.pi)*0.25*1.5
let translationZ = -itemSpacing * 0.5 * abs(position)
var transform3D = CATransform3DIdentity
transform3D.m34 = -0.002
transform3D = CATransform3DRotate(transform3D, rotation, 0, 1, 0)
transform3D = CATransform3DTranslate(transform3D, 0, 0, translationZ)
attributes.zIndex = 100 - Int(abs(position))
attributes.transform3D = transform3D
case .ferrisWheel, .invertedFerrisWheel:
guard scrollDirection == .horizontal else {
// This type doesn't support vertical mode
return
}
// http://ronnqvi.st/translate-rotate-translate/
var zIndex = 0
var transform = CGAffineTransform.identity
switch position {
case -5 ... 5:
let itemSpacing = attributes.bounds.width+self.proposedInteritemSpacing()
let count: CGFloat = 14
let circle: CGFloat = .pi * 2.0
let radius = itemSpacing * count / circle
let ty = radius * (self.type == .ferrisWheel ? 1 : -1)
let theta = circle / count
let rotation = position * theta * (self.type == .ferrisWheel ? 1 : -1)
transform = transform.translatedBy(x: -position*itemSpacing, y: ty)
transform = transform.rotated(by: rotation)
transform = transform.translatedBy(x: 0, y: -ty)
zIndex = Int((4.0-abs(position)*10))
default:
break
}
attributes.alpha = abs(position) < 0.5 ? 1 : self.minimumAlpha
attributes.transform = transform
attributes.zIndex = zIndex
case .cubic:
switch position {
case -CGFloat.greatestFiniteMagnitude ... -1:
attributes.alpha = 0
case -1 ..< 1:
attributes.alpha = 1
attributes.zIndex = Int((1-position) * CGFloat(10))
let direction: CGFloat = position < 0 ? 1 : -1
let theta = position * .pi * 0.5 * (scrollDirection == .horizontal ? 1 : -1)
let radius = scrollDirection == .horizontal ? attributes.bounds.width : attributes.bounds.height
var transform3D = CATransform3DIdentity
transform3D.m34 = -0.002
switch scrollDirection {
case .horizontal:
// ForwardX -> RotateY -> BackwardX
attributes.center.x += direction*radius*0.5 // ForwardX
transform3D = CATransform3DRotate(transform3D, theta, 0, 1, 0) // RotateY
transform3D = CATransform3DTranslate(transform3D,-direction*radius*0.5, 0, 0) // BackwardX
case .vertical:
// ForwardY -> RotateX -> BackwardY
attributes.center.y += direction*radius*0.5 // ForwardY
transform3D = CATransform3DRotate(transform3D, theta, 1, 0, 0) // RotateX
transform3D = CATransform3DTranslate(transform3D,0, -direction*radius*0.5, 0) // BackwardY
}
attributes.transform3D = transform3D
case 1 ... CGFloat.greatestFiniteMagnitude:
attributes.alpha = 0
default:
attributes.alpha = 0
attributes.zIndex = 0
}
}
}
// An interitem spacing proposed by transformer class. This will override the default interitemSpacing provided by the pager view.
open func proposedInteritemSpacing() -> CGFloat {
guard let pagerView = self.pagerView else {
return 0
}
let scrollDirection = pagerView.scrollDirection
switch self.type {
case .overlap:
guard scrollDirection == .horizontal else {
return 0
}
return pagerView.itemSize.width * -self.minimumScale * 0.6
case .linear:
guard scrollDirection == .horizontal else {
return 0
}
return pagerView.itemSize.width * -self.minimumScale * 0.2
case .coverFlow:
guard scrollDirection == .horizontal else {
return 0
}
return -pagerView.itemSize.width * sin(.pi*0.25*0.25*3.0)
case .ferrisWheel,.invertedFerrisWheel:
guard scrollDirection == .horizontal else {
return 0
}
return -pagerView.itemSize.width * 0.15
case .cubic:
return 0
default:
break
}
return pagerView.interitemSpacing
}
}
================================================
FILE: Sources/FSPagerCollectionView.swift
================================================
//
// FSPagerCollectionView.swift
// FSPagerView
//
// Created by Wenchao Ding on 24/12/2016.
// Copyright © 2016 Wenchao Ding. All rights reserved.
//
// 1. Reject -[UIScrollView(UIScrollViewInternal) _adjustContentOffsetIfNecessary]
// 2. Group initialized features
import UIKit
class FSPagerCollectionView: UICollectionView {
#if !os(tvOS)
override var scrollsToTop: Bool {
set {
super.scrollsToTop = false
}
get {
return false
}
}
#endif
override var contentInset: UIEdgeInsets {
set {
super.contentInset = .zero
if (newValue.top > 0) {
let contentOffset = CGPoint(x:self.contentOffset.x, y:self.contentOffset.y+newValue.top);
self.contentOffset = contentOffset
}
}
get {
return super.contentInset
}
}
override init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout) {
super.init(frame: frame, collectionViewLayout: layout)
self.commonInit()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.commonInit()
}
fileprivate func commonInit() {
self.contentInset = .zero
self.decelerationRate = UIScrollView.DecelerationRate.fast
self.showsVerticalScrollIndicator = false
self.showsHorizontalScrollIndicator = false
if #available(iOS 10.0, *) {
self.isPrefetchingEnabled = false
}
if #available(iOS 11.0, *) {
self.contentInsetAdjustmentBehavior = .never
}
#if !os(tvOS)
self.scrollsToTop = false
self.isPagingEnabled = false
#endif
}
}
================================================
FILE: Sources/FSPagerView.swift
================================================
//
// FSPagerView.swift
// FSPagerView
//
// 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
@objc
public protocol FSPagerViewDataSource: NSObjectProtocol {
/// Asks your data source object for the number of items in the pager view.
@objc(numberOfItemsInPagerView:)
func numberOfItems(in pagerView: FSPagerView) -> Int
/// Asks your data source object for the cell that corresponds to the specified item in the pager view.
@objc(pagerView:cellForItemAtIndex:)
func pagerView(_ pagerView: FSPagerView, cellForItemAt index: Int) -> FSPagerViewCell
}
@objc
public protocol FSPagerViewDelegate: NSObjectProtocol {
/// Asks the delegate if the item should be highlighted during tracking.
@objc(pagerView:shouldHighlightItemAtIndex:)
optional func pagerView(_ pagerView: FSPagerView, shouldHighlightItemAt index: Int) -> Bool
/// Tells the delegate that the item at the specified index was highlighted.
@objc(pagerView:didHighlightItemAtIndex:)
optional func pagerView(_ pagerView: FSPagerView, didHighlightItemAt index: Int)
/// Asks the delegate if the specified item should be selected.
@objc(pagerView:shouldSelectItemAtIndex:)
optional func pagerView(_ pagerView: FSPagerView, shouldSelectItemAt index: Int) -> Bool
/// Tells the delegate that the item at the specified index was selected.
@objc(pagerView:didSelectItemAtIndex:)
optional func pagerView(_ pagerView: FSPagerView, didSelectItemAt index: Int)
/// Tells the delegate that the specified cell is about to be displayed in the pager view.
@objc(pagerView:willDisplayCell:forItemAtIndex:)
optional func pagerView(_ pagerView: FSPagerView, willDisplay cell: FSPagerViewCell, forItemAt index: Int)
/// Tells the delegate that the specified cell was removed from the pager view.
@objc(pagerView:didEndDisplayingCell:forItemAtIndex:)
optional func pagerView(_ pagerView: FSPagerView, didEndDisplaying cell: FSPagerViewCell, forItemAt index: Int)
/// Tells the delegate when the pager view is about to start scrolling the content.
@objc(pagerViewWillBeginDragging:)
optional func pagerViewWillBeginDragging(_ pagerView: FSPagerView)
/// Tells the delegate when the user finishes scrolling the content.
@objc(pagerViewWillEndDragging:targetIndex:)
optional func pagerViewWillEndDragging(_ pagerView: FSPagerView, targetIndex: Int)
/// Tells the delegate when the user scrolls the content view within the receiver.
@objc(pagerViewDidScroll:)
optional func pagerViewDidScroll(_ pagerView: FSPagerView)
/// Tells the delegate when a scrolling animation in the pager view concludes.
@objc(pagerViewDidEndScrollAnimation:)
optional func pagerViewDidEndScrollAnimation(_ pagerView: FSPagerView)
/// Tells the delegate that the pager view has ended decelerating the scrolling movement.
@objc(pagerViewDidEndDecelerating:)
optional func pagerViewDidEndDecelerating(_ pagerView: FSPagerView)
}
@IBDesignable
open class FSPagerView: UIView,UICollectionViewDataSource,UICollectionViewDelegate {
// MARK: - Public properties
/// The object that acts as the data source of the pager view.
@IBOutlet open weak var dataSource: FSPagerViewDataSource?
/// The object that acts as the delegate of the pager view.
@IBOutlet open weak var delegate: FSPagerViewDelegate?
/// The scroll direction of the pager view. Default is horizontal.
@objc
open var scrollDirection: FSPagerView.ScrollDirection = .horizontal {
didSet {
self.collectionViewLayout.forceInvalidate()
}
}
/// The time interval of automatic sliding. 0 means disabling automatic sliding. Default is 0.
@IBInspectable
open var automaticSlidingInterval: CGFloat = 0.0 {
didSet {
self.cancelTimer()
if self.automaticSlidingInterval > 0 {
self.startTimer()
}
}
}
/// The spacing to use between items in the pager view. Default is 0.
@IBInspectable
open var interitemSpacing: CGFloat = 0 {
didSet {
self.collectionViewLayout.forceInvalidate()
}
}
/// 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 {
didSet {
self.collectionViewLayout.forceInvalidate()
}
}
/// A Boolean value indicates that whether the pager view has infinite items. Default is false.
@IBInspectable
open var isInfinite: Bool = false {
didSet {
self.collectionViewLayout.needsReprepare = true
self.collectionView.reloadData()
}
}
/// 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
/// A Boolean value that determines whether scrolling is enabled.
@IBInspectable
open var isScrollEnabled: Bool {
set { self.collectionView.isScrollEnabled = newValue }
get { return self.collectionView.isScrollEnabled }
}
/// A Boolean value that controls whether the pager view bounces past the edge of content and back again.
@IBInspectable
open var bounces: Bool {
set { self.collectionView.bounces = newValue }
get { return self.collectionView.bounces }
}
/// A Boolean value that determines whether bouncing always occurs when horizontal scrolling reaches the end of the content view.
@IBInspectable
open var alwaysBounceHorizontal: Bool {
set { self.collectionView.alwaysBounceHorizontal = newValue }
get { return self.collectionView.alwaysBounceHorizontal }
}
/// A Boolean value that determines whether bouncing always occurs when vertical scrolling reaches the end of the content view.
@IBInspectable
open var alwaysBounceVertical: Bool {
set { self.collectionView.alwaysBounceVertical = newValue }
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.
@IBInspectable
open var removesInfiniteLoopForSingleItem: Bool = false {
didSet {
self.reloadData()
}
}
/// The background view of the pager view.
@IBInspectable
open var backgroundView: UIView? {
didSet {
if let backgroundView = self.backgroundView {
if backgroundView.superview != nil {
backgroundView.removeFromSuperview()
}
self.insertSubview(backgroundView, at: 0)
self.setNeedsLayout()
}
}
}
/// The transformer of the pager view.
@objc
open var transformer: FSPagerViewTransformer? {
didSet {
self.transformer?.pagerView = self
self.collectionViewLayout.forceInvalidate()
}
}
// MARK: - Public readonly-properties
/// Returns whether the user has touched the content to initiate scrolling.
@objc
open var isTracking: Bool {
return self.collectionView.isTracking
}
/// The percentage of x position at which the origin of the content view is offset from the origin of the pagerView view.
@objc
open var scrollOffset: CGFloat {
let contentOffset = max(self.collectionView.contentOffset.x, self.collectionView.contentOffset.y)
let scrollOffset = Double(contentOffset/self.collectionViewLayout.itemSpacing)
return fmod(CGFloat(scrollOffset), CGFloat(self.numberOfItems))
}
/// The underlying gesture recognizer for pan gestures.
@objc
open var panGestureRecognizer: UIPanGestureRecognizer {
return self.collectionView.panGestureRecognizer
}
@objc open fileprivate(set) dynamic var currentIndex: Int = 0
// MARK: - Private properties
internal weak var collectionViewLayout: FSPagerViewLayout!
internal weak var collectionView: FSPagerCollectionView!
internal weak var contentView: UIView!
internal var timer: Timer?
internal var numberOfItems: Int = 0
internal var numberOfSections: Int = 0
fileprivate var dequeingSection = 0
fileprivate var centermostIndexPath: IndexPath {
guard self.numberOfItems > 0, self.collectionView.contentSize != .zero else {
return IndexPath(item: 0, section: 0)
}
let sortedIndexPaths = self.collectionView.indexPathsForVisibleItems.sorted { (l, r) -> Bool in
let leftFrame = self.collectionViewLayout.frame(for: l)
let rightFrame = self.collectionViewLayout.frame(for: r)
var leftCenter: CGFloat,rightCenter: CGFloat,ruler: CGFloat
switch self.scrollDirection {
case .horizontal:
leftCenter = leftFrame.midX
rightCenter = rightFrame.midX
ruler = self.collectionView.bounds.midX
case .vertical:
leftCenter = leftFrame.midY
rightCenter = rightFrame.midY
ruler = self.collectionView.bounds.midY
}
return abs(ruler-leftCenter) < abs(ruler-rightCenter)
}
let indexPath = sortedIndexPaths.first
if let indexPath = indexPath {
return indexPath
}
return IndexPath(item: 0, section: 0)
}
fileprivate var isPossiblyRotating: Bool {
guard let animationKeys = self.contentView.layer.animationKeys() else {
return false
}
let rotationAnimationKeys = ["position", "bounds.origin", "bounds.size"]
return animationKeys.contains(where: { rotationAnimationKeys.contains($0) })
}
fileprivate var possibleTargetingIndexPath: IndexPath?
// MARK: - Overriden functions
public override init(frame: CGRect) {
super.init(frame: frame)
self.commonInit()
}
public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.commonInit()
}
open override func layoutSubviews() {
super.layoutSubviews()
self.backgroundView?.frame = self.bounds
self.contentView.frame = self.bounds
self.collectionView.frame = self.contentView.bounds
}
open override func willMove(toWindow newWindow: UIWindow?) {
super.willMove(toWindow: newWindow)
if newWindow != nil {
self.startTimer()
} else {
self.cancelTimer()
}
}
#if TARGET_INTERFACE_BUILDER
open override func prepareForInterfaceBuilder() {
super.prepareForInterfaceBuilder()
self.contentView.layer.borderWidth = 1
self.contentView.layer.cornerRadius = 5
self.contentView.layer.masksToBounds = true
self.contentView.frame = self.bounds
let label = UILabel(frame: self.contentView.bounds)
label.textAlignment = .center
label.font = UIFont.boldSystemFont(ofSize: 25)
label.text = "FSPagerView"
self.contentView.addSubview(label)
}
#endif
deinit {
self.collectionView.dataSource = nil
self.collectionView.delegate = nil
}
// MARK: - UICollectionViewDataSource
public func numberOfSections(in collectionView: UICollectionView) -> Int {
guard let dataSource = self.dataSource else {
return 1
}
self.numberOfItems = dataSource.numberOfItems(in: self)
guard self.numberOfItems > 0 else {
return 0;
}
self.numberOfSections = self.isInfinite && (self.numberOfItems > 1 || !self.removesInfiniteLoopForSingleItem) ? Int(Int16.max)/self.numberOfItems : 1
return self.numberOfSections
}
public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return self.numberOfItems
}
public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let index = indexPath.item
self.dequeingSection = indexPath.section
let cell = self.dataSource!.pagerView(self, cellForItemAt: index)
return cell
}
// MARK: - UICollectionViewDelegate
public func collectionView(_ collectionView: UICollectionView, shouldHighlightItemAt indexPath: IndexPath) -> Bool {
guard let function = self.delegate?.pagerView(_:shouldHighlightItemAt:) else {
return true
}
let index = indexPath.item % self.numberOfItems
return function(self,index)
}
public func collectionView(_ collectionView: UICollectionView, didHighlightItemAt indexPath: IndexPath) {
guard let function = self.delegate?.pagerView(_:didHighlightItemAt:) else {
return
}
let index = indexPath.item % self.numberOfItems
function(self,index)
}
public func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool {
guard let function = self.delegate?.pagerView(_:shouldSelectItemAt:) else {
return true
}
let index = indexPath.item % self.numberOfItems
return function(self,index)
}
public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
guard let function = self.delegate?.pagerView(_:didSelectItemAt:) else {
return
}
self.possibleTargetingIndexPath = indexPath
defer {
self.possibleTargetingIndexPath = nil
}
let index = indexPath.item % self.numberOfItems
function(self,index)
}
public func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
guard let function = self.delegate?.pagerView(_:willDisplay:forItemAt:) else {
return
}
let index = indexPath.item % self.numberOfItems
function(self,cell as! FSPagerViewCell,index)
}
public func collectionView(_ collectionView: UICollectionView, didEndDisplaying cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
guard let function = self.delegate?.pagerView(_:didEndDisplaying:forItemAt:) else {
return
}
let index = indexPath.item % self.numberOfItems
function(self,cell as! FSPagerViewCell,index)
}
public func scrollViewDidScroll(_ scrollView: UIScrollView) {
if !self.isPossiblyRotating && self.numberOfItems > 0 {
// In case someone is using KVO
let currentIndex = lround(Double(self.scrollOffset)) % self.numberOfItems
if (currentIndex != self.currentIndex) {
self.currentIndex = currentIndex
}
}
guard let function = self.delegate?.pagerViewDidScroll else {
return
}
function(self)
}
public func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
if let function = self.delegate?.pagerViewWillBeginDragging(_:) {
function(self)
}
if self.automaticSlidingInterval > 0 {
self.cancelTimer()
}
}
public func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer) {
if let function = self.delegate?.pagerViewWillEndDragging(_:targetIndex:) {
let contentOffset = self.scrollDirection == .horizontal ? targetContentOffset.pointee.x : targetContentOffset.pointee.y
let targetItem = lround(Double(contentOffset/self.collectionViewLayout.itemSpacing))
function(self, targetItem % self.numberOfItems)
}
if self.automaticSlidingInterval > 0 {
self.startTimer()
}
}
public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
if let function = self.delegate?.pagerViewDidEndDecelerating {
function(self)
}
}
public func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) {
if let function = self.delegate?.pagerViewDidEndScrollAnimation {
function(self)
}
}
// 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) {
self.collectionView.register(cellClass, forCellWithReuseIdentifier: identifier)
}
/// Register a nib file for use in creating new pager view cells.
///
/// - Parameters:
/// - nib: The nib object containing the cell object. The nib file must contain only one top-level object and that object must be of the type FSPagerViewCell.
/// - identifier: The reuse identifier to associate with the specified nib file. This parameter must not be nil and must not be an empty string.
@objc(registerNib:forCellWithReuseIdentifier:)
open func register(_ nib: UINib?, forCellWithReuseIdentifier identifier: String) {
self.collectionView.register(nib, 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)
let cell = self.collectionView.dequeueReusableCell(withReuseIdentifier: identifier, for: indexPath)
guard cell.isKind(of: FSPagerViewCell.self) else {
fatalError("Cell class must be subclass of FSPagerViewCell")
}
return cell as! FSPagerViewCell
}
/// Reloads all of the data for the collection view.
@objc(reloadData)
open func reloadData() {
self.collectionViewLayout.needsReprepare = true;
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)
let scrollPosition: UICollectionView.ScrollPosition = self.scrollDirection == .horizontal ? .centeredHorizontally : .centeredVertically
self.collectionView.selectItem(at: indexPath, animated: animated, scrollPosition: scrollPosition)
}
/// 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 {
fatalError("index \(index) is out of range [0...\(self.numberOfItems-1)]")
}
let indexPath = { () -> IndexPath in
if let indexPath = self.possibleTargetingIndexPath, indexPath.item == index {
defer {
self.possibleTargetingIndexPath = nil
}
return indexPath
}
return self.numberOfSections > 1 ? self.nearbyIndexPath(for: index) : IndexPath(item: index, section: 0)
}()
let contentOffset = self.collectionViewLayout.contentOffset(for: indexPath)
self.collectionView.setContentOffset(contentOffset, animated: animated)
}
/// Returns the index of the specified cell.
///
/// - Parameter cell: The cell object whose index you want.
/// - Returns: The index of the cell or NSNotFound if the specified cell is not in the pager view.
@objc(indexForCell:)
open func index(for cell: FSPagerViewCell) -> Int {
guard let indexPath = self.collectionView.indexPath(for: cell) else {
return NSNotFound
}
return indexPath.item
}
/// Returns the visible cell at the specified index.
///
/// - Parameter index: The index that specifies the position of the cell.
/// - Returns: The cell object at the corresponding position or nil if the cell is not visible or index is out of range.
@objc(cellForItemAtIndex:)
open func cellForItem(at index: Int) -> FSPagerViewCell? {
let indexPath = self.nearbyIndexPath(for: index)
return self.collectionView.cellForItem(at: indexPath) as? FSPagerViewCell
}
// MARK: - Private functions
fileprivate func commonInit() {
// Content View
let contentView = UIView(frame:CGRect.zero)
contentView.backgroundColor = UIColor.clear
self.addSubview(contentView)
self.contentView = contentView
// UICollectionView
let collectionViewLayout = FSPagerViewLayout()
let collectionView = FSPagerCollectionView(frame: CGRect.zero, collectionViewLayout: collectionViewLayout)
collectionView.dataSource = self
collectionView.delegate = self
collectionView.backgroundColor = UIColor.clear
self.contentView.addSubview(collectionView)
self.collectionView = collectionView
self.collectionViewLayout = collectionViewLayout
}
fileprivate func startTimer() {
guard self.automaticSlidingInterval > 0 && self.timer == nil else {
return
}
self.timer = Timer.scheduledTimer(timeInterval: TimeInterval(self.automaticSlidingInterval), target: self, selector: #selector(self.flipNext(sender:)), userInfo: nil, repeats: true)
RunLoop.current.add(self.timer!, forMode: .common)
}
@objc
fileprivate func flipNext(sender: Timer?) {
guard let _ = self.superview, let _ = self.window, self.numberOfItems > 0, !self.isTracking else {
return
}
let contentOffset: CGPoint = {
let indexPath = self.centermostIndexPath
let section = self.numberOfSections > 1 ? (indexPath.section+(indexPath.item+1)/self.numberOfItems) : 0
let item = (indexPath.item+1) % self.numberOfItems
return self.collectionViewLayout.contentOffset(for: IndexPath(item: item, section: section))
}()
self.collectionView.setContentOffset(contentOffset, animated: true)
}
fileprivate func cancelTimer() {
guard self.timer != nil else {
return
}
self.timer!.invalidate()
self.timer = nil
}
fileprivate func nearbyIndexPath(for index: Int) -> IndexPath {
// Is there a better algorithm?
let currentIndex = self.currentIndex
let currentSection = self.centermostIndexPath.section
if abs(currentIndex-index) <= self.numberOfItems/2 {
return IndexPath(item: index, section: currentSection)
} else if (index-currentIndex >= 0) {
return IndexPath(item: index, section: currentSection-1)
} else {
return IndexPath(item: index, section: currentSection+1)
}
}
}
extension FSPagerView {
/// Constants indicating the direction of scrolling for the pager view.
@objc
public enum ScrollDirection: Int {
/// The pager view scrolls content horizontally
case horizontal
/// The pager view scrolls content vertically
case vertical
}
/// Requests that FSPagerView use the default value for a given distance.
public static let automaticDistance: UInt = 0
/// Requests that FSPagerView use the default value for a given size.
public static let automaticSize: CGSize = .zero
}
================================================
FILE: Sources/FSPagerViewCell.swift
================================================
//
// FSPagerViewCell.swift
// FSPagerView
//
// Created by Wenchao Ding on 17/12/2016.
// Copyright © 2016 Wenchao Ding. All rights reserved.
//
import UIKit
open class FSPagerViewCell: UICollectionViewCell {
/// Returns the label used for the main textual content of the pager view cell.
@objc
open var textLabel: UILabel? {
if let _ = _textLabel {
return _textLabel
}
let view = UIView(frame: .zero)
view.isUserInteractionEnabled = false
view.backgroundColor = UIColor.black.withAlphaComponent(0.6)
let textLabel = UILabel(frame: .zero)
textLabel.textColor = .white
textLabel.font = UIFont.preferredFont(forTextStyle: .body)
self.contentView.addSubview(view)
view.addSubview(textLabel)
textLabel.addObserver(self, forKeyPath: "font", options: [.old,.new], context: kvoContext)
_textLabel = textLabel
return textLabel
}
/// Returns the image view of the pager view cell. Default is nil.
@objc
open var imageView: UIImageView? {
if let _ = _imageView {
return _imageView
}
let imageView = UIImageView(frame: .zero)
self.contentView.addSubview(imageView)
_imageView = imageView
return imageView
}
fileprivate weak var _textLabel: UILabel?
fileprivate 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? {
guard _selectedForegroundView == nil else {
return _selectedForegroundView
}
guard let imageView = _imageView else {
return nil
}
let view = UIView(frame: imageView.bounds)
imageView.addSubview(view)
_selectedForegroundView = view
return view
}
open override var isHighlighted: Bool {
set {
super.isHighlighted = newValue
if newValue {
self.selectedForegroundView?.layer.backgroundColor = self.selectionColor.cgColor
} else if !super.isSelected {
self.selectedForegroundView?.layer.backgroundColor = UIColor.clear.cgColor
}
}
get {
return super.isHighlighted
}
}
open override var isSelected: Bool {
set {
super.isSelected = newValue
self.selectedForegroundView?.layer.backgroundColor = newValue ? self.selectionColor.cgColor : UIColor.clear.cgColor
}
get {
return super.isSelected
}
}
public override init(frame: CGRect) {
super.init(frame: frame)
commonInit()
}
public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
commonInit()
}
fileprivate func commonInit() {
self.contentView.backgroundColor = UIColor.clear
self.backgroundColor = UIColor.clear
self.contentView.layer.shadowColor = UIColor.black.cgColor
self.contentView.layer.shadowRadius = 5
self.contentView.layer.shadowOpacity = 0.75
self.contentView.layer.shadowOffset = .zero
}
deinit {
if let textLabel = _textLabel {
textLabel.removeObserver(self, forKeyPath: "font", context: kvoContext)
}
}
override open func layoutSubviews() {
super.layoutSubviews()
if let imageView = _imageView {
imageView.frame = self.contentView.bounds
}
if let textLabel = _textLabel {
textLabel.superview!.frame = {
var rect = self.contentView.bounds
let height = textLabel.font.pointSize*1.5
rect.size.height = height
rect.origin.y = self.contentView.frame.height-height
return rect
}()
textLabel.frame = {
var rect = textLabel.superview!.bounds
rect = rect.insetBy(dx: 8, dy: 0)
rect.size.height -= 1
rect.origin.y += 1
return rect
}()
}
if let selectedForegroundView = _selectedForegroundView {
selectedForegroundView.frame = self.contentView.bounds
}
}
open override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
if context == kvoContext {
if keyPath == "font" {
self.setNeedsLayout()
}
} else {
super.observeValue(forKeyPath: keyPath, of: object, change: change, context: context)
}
}
}
================================================
FILE: Sources/FSPagerViewLayoutAttributes.swift
================================================
//
// FSPagerViewLayoutAttributes.swift
// FSPagerViewExample
//
// Created by Wenchao Ding on 26/02/2017.
// Copyright © 2017 Wenchao Ding. All rights reserved.
//
import UIKit
open class FSPagerViewLayoutAttributes: UICollectionViewLayoutAttributes {
open var position: CGFloat = 0
open override func isEqual(_ object: Any?) -> Bool {
guard let object = object as? FSPagerViewLayoutAttributes else {
return false
}
var isEqual = super.isEqual(object)
isEqual = isEqual && (self.position == object.position)
return isEqual
}
open override func copy(with zone: NSZone? = nil) -> Any {
let copy = super.copy(with: zone) as! FSPagerViewLayoutAttributes
copy.position = self.position
return copy
}
}
================================================
FILE: Sources/FSPagerViewObjcCompat.h
================================================
//
// FSPagerViewObjcCompat.h
// FSPagerView
//
// Created by 丁文超 on 2018/9/18.
// Copyright © 2018 Wenchao Ding. All rights reserved.
//
#import
#import
#define FSPagerViewExtern extern
/**
Requests that FSPagerView use the default value for a given distance.
*/
FSPagerViewExtern NSUInteger const FSPagerViewAutomaticDistance;
/**
Requests that FSPagerView use the default value for a given size.
*/
FSPagerViewExtern CGSize const FSPagerViewAutomaticSize;
================================================
FILE: Sources/FSPagerViewObjcCompat.m
================================================
//
// FSPagerViewObjcCompat.m
// FSPagerView
//
// Created by Wenchao Ding on 2018/9/24.
// Copyright © 2018 Wenchao Ding. All rights reserved.
//
#import "FSPagerViewObjcCompat.h"
NSUInteger const FSPagerViewAutomaticDistance = 0;
CGSize const FSPagerViewAutomaticSize = { .width = 0, .height = 0 };