Supports Swift 3
A horizontal scoller view that makes its collection view cells full screen and can optionally wire UIPageControl and a previous and next UIbuttons.
It doesn't affect the appearance of the controls and doesn't implement the collection view data source to keep full flexibility while doing the repeated work for a horizontal scroller.
- iOS 7.0+ / Mac OS X 10.9+
- Xcode 8.0
- Swift 3.0
- Drag and drop a
UIView
. - Change the class name to
PagedHorizontalView
from identity inspector. - Drag and drop a
UICollectionView
, use the defaults. - Optionally drag and drop a
UIPageControl
- Optionally drag and drop 2
UIButtons
for next and previous - Wire the
UICollectionView
to thePagedHorizontalView
- Wire the
UIPageControl
to thePagedHorizontalView
either the reference outletpageControl
or thepageChanged:
action. But not both. - Wire the 2
UIButtons
either the reference outletnextButton
andpreviousButton
or touch up inside action withgoToNextPage
andgoToPreviousPage
. But not both, wiring the action and the reference outlet will give unexpected behavior.
Alternatively, you can create it from code just as you create a normal UIView
and set the properties instead of wiring them as described above for collectionView
, pageControl
, etc.
You need to set a layout object of kind UICollectionViewFlowLayout
for the UICollectionView
.
In both cases programmatically or using interface builder, you should set the dataSource
for the UICollectionView
yourself. This way, you have full flexibility to specify the layout of the scrolling content.
For iOS 8 or later:
PagedHorizontalView is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "PagedHorizontalView"
For iOS 7.x:
Embedded frameworks require a minimum deployment target of iOS 8.
To use PagedHorizontalView with a project targeting iOS 7, you must include PagedHorizontalView.swift directly into your project.
Mohamed Afifi, mohamede1945@gmail.com
PagedHorizontalView is available under the MIT license. See the LICENSE file for more info.