Latest 1.1.0
Homepage https://github.com/h-yuya/Showcase
License MIT
Platforms ios 9.0
Frameworks UIKit
Authors

Showcase

![SwiftVersion](https://img.shields.io/badge/language-swift3-orange.svg?style=flat)
![SwiftVersion](https://img.shields.io/badge/language-swift4-orange.svg?style=flat)
[![Version](https://img.shields.io/cocoapods/v/Showcase.svg?style=flat)](http://cocoapods.org/pods/Showcase)
![Version](https://img.shields.io/badge/Carthage-compatible-yellow.svg?style=flat)
[![License](https://img.shields.io/cocoapods/l/Showcase.svg?style=flat)](http://cocoapods.org/pods/Showcase)
[![Platform](https://img.shields.io/cocoapods/p/Showcase.svg?style=flat)](http://cocoapods.org/pods/Showcase)

## Basic Overview
Showcase is a UIView based view to display any views in the frame, like you display figures in a shelf or showcase.

## Feature
– Protocol based – Type-safe for view and model, does not require overriding any special view.
– Looping – Loop first cell to last cell or last cell to first cell being reused.
– Paging – Can enable showcase cell size paging.
– Layout – Customize your own layout.

## Installation

### [CocoaPods](https://cocoapods.org/)
Add the following to your Podfile:
“`ruby
use_frameworks!

target ‘TargetName’ do
pod ‘Showcase’
end
“`

### [Carthage](https://github.com/Carthage/Carthage)
Add the following to your Package.swift:
“`swift
github “h-yuya/Showcase”
“`

## How to Use
Configure UIView in the storyboard and set custom class to `Showcase`
![storyboard](./Resources/storyboard.png)
#### First, make a view you want to display and model are needed for configuration of the view conform to `ReusableView` and `ReusableModel` protocol.
“`swift
import UIKit
import Showcase

struct ColorModel: ReusableModel {
let color: UIColor

init(color: UIColor) {
self.color = color
}
}

final class ColorView: ReusableView {
typealias Model = ColorModel

func configure(with model: ColorModel) {
backgroundColor = model.color
}

override func awakeFromNib() {
super.awakeFromNib()
configureAppearance()
}
}

private extension ColorView {
func configureAppearance() {
layer.cornerRadius = 30
clipsToBounds = true
}
}
“`
– `typealias Model`
– `Model` is a model to configure the view
– `typealias` it to any model conforming to `ReusableModel` .

– `func configure(with model: Model)`
– As its name suggests, configure the view with `Model`

#### Second, configure showcase in the ViewController.
“`swift
import UIKit
import Showcase

final class ColorViewController: UIViewController {
// UIView is the super class of Showcase
@IBOutlet fileprivate weak var showcase: Showcase!
fileprivate let colors: [UIColor] = [.red, .green, .blue, .yellow, .gray]

override func viewDidLoad() {
super.viewDidLoad()
configure()
}
}

private extension ColorViewController {
func configure() {
let models = colors.map(ColorModel.init(color:))

showcase.layout.direction = .horizontal
showcase.layout.itemSize = .init(width: 300, height: 300)

// registered view is able to be used for resetting showcase.
showcase.register(byNibName: ColorView.self)

// Type-safely reset the showcase. You can call this method any number of times.
// views used for resetting must be registered before resetting.
showcase.reset(ColorView.self, models: models)

// The type is used as the identifier for reuse
}
}
“`
#### Everything has done. Let’s watch the demo.

![simple_horizontal](./Resources/simple_hor.gif)
![simple_vertical](./Resources/simple_ver.gif)

Do you want to do paging with each view sizes??
OK, add just `showcase.isPagingEnabled = true` before resetting.

![simple_horizontal_p](./Resources/simple_hor_p.gif)
![simple_vertical_p](./Resources/simple_ver_p.gif)

## Layout

Showcase have a layout property. You can design your layout easily.
These are all properties layout has.
### Showcase.layout
– `direction`: LayoutDirection => .horizontal or .vertical
– `itemSize`: CGSize => item size
– `lineSpacing`: CGFloat => spacing between each cell
– `path`: PathProtocol => path, view’s orbit drawn by scrolling
– `transform`: TransformProtocol? => view’s shape is transformed by scrolling

The Speciality is `path` and `transform` property.
### Definition & Feature of PathProtocol and TransformProtocol
“`swift
public protocol PathProtocol {
func normalizedPath(withCoordinate value: CGFloat) -> CGFloat
}
“`
“`swift
public protocol TransformProtocol {
func transform(withScrollingRate rate: CGFloat) -> CATransform3D
}
“`
– Normalized coordinate
– Can create your own designed path, conforming to PathProtocol

Latest podspec

{
    "name": "Showcase",
    "version": "1.1.0",
    "summary": "Showcase is a UIView based view to display views in the frame, like you display figures in a sheld or showcase",
    "description": "Type-safely resettingnLooping for last cell to first cell.nPaging can be enabled with each cell size.nLayout makes Showcase much customizable. You can create your own path and transform.",
    "homepage": "https://github.com/h-yuya/Showcase",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "h-yuya": "[email protected]"
    },
    "source": {
        "git": "https://github.com/h-yuya/Showcase.git",
        "tag": "1.1.0"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source_files": "Sources/**/*",
    "frameworks": "UIKit",
    "pushed_with_swift_version": "3.2"
}

Pin It on Pinterest

Share This