• Stars
    star
    168
  • Rank 225,507 (Top 5 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 8 years ago
  • Updated about 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Library provides easy to implement variation of Android (Material Design) Floating Action Button for iOS. You can use it as your app small side menu. ๐ŸŒถ

Version License Platform Language Twitter

RHSideButtons ๐ŸŒถ

Library provides easy to implement variation of Android (Material Design) Floating Action Button for iOS. You can use it as your app small side menu. ๐ŸŒถ

Play with it ๐Ÿ˜Ž

Installation

You can install RHSideButtons library using CocoaPods:

pod 'RHSideButtons'

or you can simply copy RHSideButtons folder to your project.

Usage

You just need implement RHSideButtonsDataSource and RHSideButtonsDelegate similar to well-known UIKit design.

// You need to firstly create trigger button. You can do this using block or your builder object which should conform to 'RHButtonViewConfigProtocol'
// RHTriggerButtonView allows you to change image for pressed state! ๐Ÿ‘Œ๐Ÿป
let triggerButton = RHTriggerButtonView(pressedImage: UIImage(named: "exit_icon")!) {
    $0.image = UIImage(named: "trigger_img")
    $0.hasShadow = true
}

// Then you need to create instance of SideButtons coordinator class with your View Controller view (it can be even TableView)
sideButtonsView = RHSideButtons(parentView: view, triggerButton: triggerButton)
sideButtonsView.delegate = self
sideButtonsView.dataSource = self

// When SideButtons controller is initialized properly you should set thier position in view in e.g. viewWillAppear method:
override func viewWillAppear(animated: Bool) {
    super.viewWillAppear(animated)

    sideBttns?.setTriggerButtonPosition(CGPoint(x: bounds.width - 85, y: bounds.height - 85))
}

... let us prepare our data models for buttons ๐Ÿ’ฅ below you can see one of many ways to do this:

//Finally you should create array of buttons which will feed our dataSource and Delegate methods :) e.g.:
let button_1 = RHButtonView {
    $0.image = UIImage(named: "icon_1")
    $0.hasShadow = true
}

let button_2 = RHButtonView {
    $0.image = UIImage(named: "icon_2")
    $0.hasShadow = true
}

let button_3 = RHButtonView {
    $0.image = UIImage(named: "icon_3")
    $0.hasShadow = true
}

buttonsArr.appendContentsOf([button_1, button_2, button_3])

//Similar as it is in TableView, now you should reload buttons with new values
sideButtonsView.reloadButtons()

๐Ÿ’ก important thing is that you need to reload buttons when your datasource has changed using reloadButtons() method (๐Ÿ˜ฑ simple rightโ“)

RHSideButtonsDataSource

func sideButtonsNumberOfButtons(sideButtons: RHSideButtons) -> Int
func sideButtons(sideButtons: RHSideButtons, buttonAtIndex index: Int) -> RHButtonView

RHSideButtonsDelegate

func sideButtons(sideButtons: RHSideButtons, didSelectButtonAtIndex index: Int)
func sideButtons(sideButtons: RHSideButtons, didTriggerButtonChangeStateTo state: RHButtonState)

Support for left-handers :)

If you decide to position RHSideButtons on the left site of view, buttons will dissapears to the left side of screen automatically.

e.g.:

sideBttns?.setTriggerButtonPosition(CGPoint(x:25, y: frame.size.height - 85))

Swift support

Library ver Swift ver
1.0 2.2
1.0.1 3.0
1.1.0 4.0

Check the Demo project

Please check out the demo project, you can see there what is the best (in my opinion ๐Ÿค”) way to implement my buttons. Please keep in mind that Readme contains the simplest way to implement this control.

More Repositories

1

RHPreviewCell

I envied so much Spotify iOS app this great playlist preview cell ๐Ÿ˜, I decided to create my own one ๐ŸŒถ. Now you can give your users ability to quick check "what content is hidden under your UITableViewCell". Great think is that this Library not requires 3D Touch support from user device๐Ÿ’ฅ.
Swift
385
star
2

RHPlaceholder

Show pleasant loading view for your users ๐Ÿ˜
Makefile
237
star
3

SkrybaMD

Swifty powered ๐Ÿ”ŒMarkdown Documentation generator. If your team need easy way to maintain and create documentation, this generator is for you.
Swift
18
star
4

Instasoup

#SwiftUI mirroring of Instagram app Home screen
Swift
12
star
5

RHSwipeableCell

RHSwipeableCell gives you simple and cool looking custom cell with extra button after swipe action.
Swift
4
star
6

RHPlaygroundFreestyle

Sometimes I try to draw something in Playground, and if I decide whether it should be kept for the future usage, I will put this piece of .playground code in this repo ๐Ÿฐ
Swift
3
star
7

BitBayJS_terminal

Because life is way easier if you can check your currencies on BitBay through terminal... ๐Ÿ™ƒ
JavaScript
3
star
8

RHAnalogClock

Clock - my very old project, I'm afraid that he will be no longer developed. ๐Ÿ˜”
Objective-C
2
star
9

RHLifoOperationQueue

Simple implementation of LIFO algorithm for NSOperationQueue
Swift
1
star
10

Language

Because for english learning purposes most of the times I create .xlsx file with words to learn, I have created for myself small script for training words randomly fetched from .xlsx file. ๐Ÿ“–
Ruby
1
star
11

XcodeTheme-Rapha.cc

You are Road Cycling lover? โค๏ธhere you have: Xcode theme inspired by Rapha.cc ๐Ÿšดโ€โ™€๏ธcolors
1
star
12

wallapopNotifier

Because you don't have opportunity to `subscribe` for particular search and receiving notification in wallapop.es website or mobile app, I created quite simple mechanism to getting those according to defined keywords/filters.
1
star