Skip to content

It shows the Left and Right Items little by little, and shows the items of the ScrollView.

License

Notifications You must be signed in to change notification settings

mrgamza/MarginScrollView

Repository files navigation

MarginScrollView

CI Status Version License Platform

Screenshot

First View and Second View

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

and add your project. import MarginScrollView and view create and set scrollView.item

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        let view1 = UIView(frame: CGRect(x: 0, y: 0, width: view.frame.width * 0.8, height: 100))
        view1.backgroundColor = .yellow
        let view2 = UIView(frame: CGRect(x: 0, y: 0, width: view.frame.width * 0.8, height: 200))
        view2.backgroundColor = .red
        let view3 = UIView(frame: CGRect(x: 0, y: 0, width: view.frame.width * 0.8, height: 300))
        view3.backgroundColor = .blue
        let view4 = UIView(frame: CGRect(x: 0, y: 0, width: view.frame.width * 0.8, height: 70))
        view4.backgroundColor = .yellow
        let view5 = UIView(frame: CGRect(x: 0, y: 0, width: view.frame.width * 0.8, height: 250))
        view5.backgroundColor = .red
        let view6 = UIView(frame: CGRect(x: 0, y: 0, width: view.frame.width * 0.8, height: 100))
        view6.backgroundColor = .blue
        
        let scrollView = MarginScrollView()
        scrollView.backgroundColor = .black
        scrollView.align = .top
        view.addSubview(scrollView)
        
        scrollView.items = [view1, view2, view3, view4, view5, view6]
        
        NSLayoutConstraint.activate([
            scrollView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
            scrollView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
            scrollView.centerYAnchor.constraint(equalTo: view.centerYAnchor)
        ])
    }
}

Properties

  1. Align set align enum value
  • top : Top Align
  • center : Center Align
  • bottom : Bottom Align
  1. items Set View Item

  2. edgeInsets MarginScrollView's edge Insets

  3. decorate inner item decorate. default is DefaultDecorate

public protocol Decorateable {
    var itemWidth: CGFloat { get }
    var itemSpacing: CGFloat { get }
}

public struct DefaultDecorate : Decorateable {
    public var itemWidth: CGFloat = UIScreen.main.bounds.width * 0.8
    public var itemSpacing: CGFloat = 15
}

Requirements

Installation

MarginScrollView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'MarginScrollView'

Author

Donghyuk Lee, [email protected]

License

MarginScrollView is available under the MIT license. See the LICENSE file for more info.

About

It shows the Left and Right Items little by little, and shows the items of the ScrollView.

Resources

License

Stars

Watchers

Forks

Packages

No packages published