StackBarButtonItem 0.1.1

StackBarButtonItem 0.1.1

Maintained by funzin.



 
Depends on:
RxSwift~> 5.0.0
RxCocoa~> 5.0.0
 

  • By
  • funzin

StackBarButtonItem

StackBarButtonItem

Platform Language Carthage
Version License

StackBarButtonItem can use BarButtonItem like stackView.

Features

  • NavigationBar margin
  • Spacing between view
  • Reverse view

Support

  • Device: iPad | iPhone
  • Orientation: Portrait | Landscape
  • Multitasking

Requirements

  • Xcode10 or greater
  • iOS9 or greater
  • Swift4.2 or greater

Dependencies

Installation

Carthage

If you’re using Carthage, simply add StackBarButtonItem to your Cartfile:

github "funzin/StackBarButtonItem"

CocoaPods

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

pod 'StackBarButtonItem'

Usage

Correspondence Table

position Default StackBarButtonItem
right navigationItem.setRightBarButtonItems navigationItem.right.setStackBarButtonItems
left navigationItem.setLeftBarButtonItems navigationItem.left.setStackBarButtonItems

Introduction

iOS11 or later

If iOS version is iOS11 or later, you must use autolayout.

import StackBarButtonItem
・
・
・

// use autolayout
let rightButton = UIButton(frame: CGRect(x: 0, y: 0, width: 44, height: 44))
NSLayoutConstraint.activate([
    rightButton.widthAnchor.constraint(equalToConstant: 44),
    rightButton.heightAnchor.constraint(equalToConstant: 44)
])
self.navigationItem.right.setStackBarButtonItems(views: [rightButton])

iOS9 or iOS10

If iOS version is iOS9 or iOS10, you must configure frame.

import StackBarButtonItem
・
・
・

// configure frame
let rightButton = UIButton(frame: CGRect(x: 0, y: 0, width: 44, height: 44))
self.navigationItem.right.setStackBarButtonItems(views: [rightButton])

Margin

// e.g. set margin to 10
self.navigationItem.right.setStackBarButtonItems(views: [rightButton], margin: 10)

Example

Margin ScreenShot
margin == 0
margin == 10

Spacing

// e.g. set spacing to 10
self.navigationItem.right.setStackBarButtonItems(views: [rightButton1, rightButton2], spacing: 10)

Example

Spacing ScreenShot
spacing == 0
spacing == 10

Reverse

// e.g. set reversed to true
self.navigationItem.right.setStackBarButtonItems(views: [rightButton1, rightButton2], reversed: true)

Example

Reverse ScreenShot
reversed == false
reversed == true

Demo

If you are interested in StackBarButtonItem, please check demo after carthage update

Author

funzin, [email protected]

License

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