Skip to content

Commit

Permalink
1. Add 'removesInfiniteLoopForSingleItem' for FSPagerView
Browse files Browse the repository at this point in the history
2. Add 'alwaysBounceVertical' and 'alwaysBounceHorizontal' for FSPagerView
3. Add 'hidesForSinglePage' for FSPageControl
4. Update Examples
  • Loading branch information
WenchaoD committed Sep 7, 2017
1 parent fc48cda commit fcef559
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 69 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="65m-zG-Zjb">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16G29" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="65m-zG-Zjb">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
Expand Down Expand Up @@ -129,6 +129,11 @@
<constraints>
<constraint firstAttribute="width" secondItem="CTG-eH-B7s" secondAttribute="height" multiplier="375:193" id="rZx-r3-VSz"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="boolean" keyPath="alwaysBounceHorizontal" value="YES"/>
<userDefinedRuntimeAttribute type="boolean" keyPath="removesInfiniteLoopForSingleItem" value="YES"/>
<userDefinedRuntimeAttribute type="boolean" keyPath="isInfinite" value="YES"/>
</userDefinedRuntimeAttributes>
<connections>
<outlet property="dataSource" destination="8S4-ui-raa" id="LYI-MJ-msM"/>
<outlet property="delegate" destination="8S4-ui-raa" id="ZXc-ha-CLU"/>
Expand All @@ -139,16 +144,19 @@
<constraints>
<constraint firstAttribute="height" constant="25" id="wm0-Qk-cZE"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="boolean" keyPath="hidesForSinglePage" value="YES"/>
</userDefinedRuntimeAttributes>
</view>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="yIp-0M-Jf9">
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" delaysContentTouches="NO" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="yIp-0M-Jf9">
<rect key="frame" x="0.0" y="257" width="375" height="410"/>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="400" id="pAf-pQ-W1L"/>
</constraints>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="cell" textLabel="tk3-eI-HIS" style="IBUITableViewCellStyleDefault" id="VNC-TS-zto">
<rect key="frame" x="0.0" y="55.5" width="375" height="44"/>
<rect key="frame" x="0.0" y="56" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="VNC-TS-zto" id="zR3-db-xZl">
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
Expand All @@ -165,10 +173,10 @@
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="slider_cell" id="RaL-gg-XJm">
<rect key="frame" x="0.0" y="99.5" width="375" height="44"/>
<rect key="frame" x="0.0" y="100" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="RaL-gg-XJm" id="i4q-nX-6cD">
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<slider opaque="NO" tag="100" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="1" minValue="0.0" maxValue="1" translatesAutoresizingMaskIntoConstraints="NO" id="bXH-0y-EZe">
Expand Down Expand Up @@ -250,7 +258,7 @@
</constraints>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="cell" textLabel="zyL-iX-55x" style="IBUITableViewCellStyleDefault" id="5d8-B4-K8u">
<rect key="frame" x="0.0" y="55.5" width="375" height="44"/>
<rect key="frame" x="0.0" y="56" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="5d8-B4-K8u" id="uyz-07-btn">
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
Expand Down Expand Up @@ -325,7 +333,7 @@
</constraints>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="cell" textLabel="BsM-5g-055" style="IBUITableViewCellStyleDefault" id="xKM-zP-mhA">
<rect key="frame" x="0.0" y="55.5" width="375" height="44"/>
<rect key="frame" x="0.0" y="56" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="xKM-zP-mhA" id="e6f-eC-LPJ">
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
Expand All @@ -342,10 +350,10 @@
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="slider_cell" id="5vo-WJ-LAV">
<rect key="frame" x="0.0" y="99.5" width="375" height="44"/>
<rect key="frame" x="0.0" y="100" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="5vo-WJ-LAV" id="4El-3j-sQo">
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<slider opaque="NO" tag="100" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="1" minValue="0.0" maxValue="1" translatesAutoresizingMaskIntoConstraints="NO" id="po6-ni-APz">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import UIKit

class BasicExampleViewController: UIViewController,UITableViewDataSource,UITableViewDelegate,FSPagerViewDataSource,FSPagerViewDelegate {

fileprivate let sectionTitles = ["Configurations", "Item Size", "Interitem Spacing"]
fileprivate let sectionTitles = ["Configurations", "Item Size", "Interitem Spacing", "Number Of Items"]
fileprivate let configurationTitles = ["Automatic sliding","Infinite"]
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! {
Expand All @@ -30,18 +31,6 @@ class BasicExampleViewController: UIViewController,UITableViewDataSource,UITable
}
}

@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]
default:
break
}
}

// MARK:- UITableViewDataSource

func numberOfSections(in tableView: UITableView) -> Int {
Expand All @@ -53,7 +42,7 @@ class BasicExampleViewController: UIViewController,UITableViewDataSource,UITable
switch section {
case 0:
return self.configurationTitles.count
case 1,2:
case 1,2,3:
return 1
default:
break
Expand Down Expand Up @@ -85,13 +74,25 @@ class BasicExampleViewController: UIViewController,UITableViewDataSource,UITable
let value: CGFloat = (0.5-scale)*2
return Float(value)
}()
slider.isContinuous = true
return cell
case 2:
// Interitem Spacing
let cell = tableView.dequeueReusableCell(withIdentifier: "slider_cell")!
let slider = cell.contentView.subviews.first as! UISlider
slider.tag = indexPath.section
slider.value = Float(self.pagerView.interitemSpacing.divided(by: 20.0))
slider.isContinuous = true
return cell
case 3:
// Number Of Items
let cell = tableView.dequeueReusableCell(withIdentifier: "slider_cell")!
let slider = cell.contentView.subviews.first as! UISlider
slider.tag = indexPath.section
slider.minimumValue = 1.0 / 7
slider.maximumValue = 1.0
slider.value = Float(self.numberOfItems) / 7.0
slider.isContinuous = false
return cell
default:
break
Expand Down Expand Up @@ -131,7 +132,7 @@ class BasicExampleViewController: UIViewController,UITableViewDataSource,UITable
// MARK:- FSPagerView DataSource

public func numberOfItems(in pagerView: FSPagerView) -> Int {
return self.imageNames.count
return self.numberOfItems
}

public func pagerView(_ pagerView: FSPagerView, cellForItemAt index: Int) -> FSPagerViewCell {
Expand All @@ -158,6 +159,21 @@ class BasicExampleViewController: UIViewController,UITableViewDataSource,UITable
self.pageControl.currentPage = pagerView.currentIndex // Or Use KVO with property "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
}
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class PageControlExampleViewController: UIViewController,UITableViewDataSource,U
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
}
}

Expand Down
2 changes: 1 addition & 1 deletion FSPagerView.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "FSPagerView"
s.version = "0.5.5"
s.version = "0.6.0"
s.summary = "FSPagerView is an elegant Screen Slide Library for making Banner、Product Show、Welcome/Guide Pages、Screen/ViewController Sliders."

s.homepage = "https://github.com/WenchaoD/FSPagerView"
Expand Down
2 changes: 1 addition & 1 deletion FSPagerView/FSPagerView/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.5.5</string>
<string>0.6.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
Loading

0 comments on commit fcef559

Please sign in to comment.