Awesome autolayout Toolbar. Toolbar is a library for iOS. You can easily create chat InputBar.

Overview

Toolbar

Version Platform Downloads

This toolbar is made with Autolayout. It works more interactively than UIToolbar.

Please Donate

Slow Animations Debug mode

If you want a Toolbar that works with the keyboard, please see here. https://github.com/1amageek/OnTheKeyboard

Installation

CocoaPods

  • Inset pod 'Toolbar' to your Podfile.
  • Run pod install

Usage

Height and Width of the Toolbar are determined automatically. Do not set frame.

Initialization.

let toolbar: Toolbar = Toolbar()
let toolbar: Toolbar = Toolbar()

lazy var camera: ToolbarItem = {
    let item: ToolbarItem = ToolbarItem(image: #imageLiteral(resourceName: "camera"), target: nil, action: nil)
    return item
}()

lazy var microphone: ToolbarItem = {
    let item: ToolbarItem = ToolbarItem(image: #imageLiteral(resourceName: "microphone"), target: nil, action: nil)
    return item
}()

lazy var picture: ToolbarItem = {
    let item: ToolbarItem = ToolbarItem(image: #imageLiteral(resourceName: "picture"), target: nil, action: nil)
    return item
}()

var toolbarBottomConstraint: NSLayoutConstraint?

override func loadView() {
    super.loadView()
    self.view.addSubview(toolbar)
    self.toolbarBottomConstraint = self.toolbar.bottomAnchor.constraint(equalTo: self.view.bottomAnchor, constant: 0)
    self.toolbarBottomConstraint?.isActive = true
}

override func viewDidLoad() {
    super.viewDidLoad()
    self.toolbar.maximumHeight = 100
    self.toolbar.setItems([self.camera, self.picture, self.microphone], animated: false)
}

Hide items

func hideItems() {
    self.camera.setHidden(false, animated: true)
    self.microphone.setHidden(false, animated: true)
    self.picture.setHidden(false, animated: true)
}

Stretchable TextView

You can control the height by setting maximumHeight.

// ViewController

override func viewDidLoad() {
    super.viewDidLoad()
    self.toolbar.maximumHeight = 100
    let textView: UITextView = UITextView(frame: .zero)
    textView.delegate = self
    textView.font = UIFont.systemFont(ofSize: 14)
    self.toolbar.setItems([textView], animated: false)
}

// UITextViewDelegate
func textViewDidChange(_ textView: UITextView) {
    let size: CGSize = textView.sizeThatFits(textView.bounds.size)
    if let constraint: NSLayoutConstraint = self.constraint {
        textView.removeConstraint(constraint)
    }
    self.constraint = textView.heightAnchor.constraint(equalToConstant: size.height)
    self.constraint?.priority = UILayoutPriorityDefaultHigh
    self.constraint?.isActive = true
}

var constraint: NSLayoutConstraint?
Comments
  • TextView doesn't show on iPhone X

    TextView doesn't show on iPhone X

    Making the toolbar anchored to the bottom of the screen doesn't work on iphone x! Specifically the textview doesn't show, looks like something is wrong with the size of it.

    screen shot 2018-01-15 at 13 50 44

    (Running example code in the screenshot above)

    works fine on other devices.

    Any solution?

    opened by majid701 6
  • Unrecognized selector

    Unrecognized selector

    import UIKit
    import Toolbar
    
    class ViewController: UIViewController {
      
      lazy var toolbar: Toolbar = {
        let toolbar: Toolbar = Toolbar([
          Toolbar.Item(title: "BUTTON", target: nil, action: #selector(test(_:))),
          Toolbar.Item(title: "BUTTON", target: nil, action: nil),
          Toolbar.Item(title: "BUTTON", target: nil, action: nil)
        ])
        return toolbar
      }()
      
      
      override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = .systemBackground
        self.view.addSubview(self.toolbar)
      }
      
      @objc func test(_ sender: Any) {
        print("hello")
      }
    }
    

    Why does the first button crash: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull test:]: unrecognized selector sent to instance 0x1de715eb0' terminating with uncaught exception of type NSException CoreSimulator 802.6 - Device: iPhone 13 mini (41207433-2958-4380-93E0-D0448B566794) - Runtime: iOS 15.4 (19E240) - DeviceType: iPhone 13 mini (lldb)

    Can you update your demo to show the buttons working?

    opened by alamodey 0
  • Toolbar disappears under keyboard

    Toolbar disappears under keyboard

    I saw the video demo on this Github page, so I thought the toolbar is meant to move relative to the keyboard. But am I actually meant to use the other repository? IMG_6926 IMG_6927

    opened by alamodey 0
  • UIView.layoutFittingCompressedSize was renamed to UILayoutFittingCompressedSize

    UIView.layoutFittingCompressedSize was renamed to UILayoutFittingCompressedSize

    [REQUIRED] Step 1: Describe your environment

    • Xcode version: 11.03
    • Toolbar version: 0.6.1

    [REQUIRED] Step 3: Describe the problem

    Compilation Error since the rename

    Steps to reproduce:

    Compile What happened? How can we make the problem occur? This could be a description, log/console output, screenshot etc.

    Relevant Code:

    public var minimumWidth: CGFloat {
        if let label: UILabel = self.titleLabel {
            let size: CGSize = label.systemLayoutSizeFitting(UILayoutFittingCompressedSize)
            return self.contentInset.left + size.width + self.contentInset.right
        }
        
        if let view: UIImageView = self.imageView {
            let size: CGSize = view.systemLayoutSizeFitting(UILayoutFittingCompressedSize)
            return self.contentInset.left + size.width + self.contentInset.right
        }
        
        if let _: UIView = self.customView {
            return self.contentInset.left + self.width + self.contentInset.right
        }
        
        return self.width
    }
    
    // TODO(you): code here to reproduce the problem
    
    opened by ohadk 0
  • maximumHeight not working on Swift 4.2

    maximumHeight not working on Swift 4.2

    • Xcode version: 10.1
    • Toolbar version: 0.5.0 using this code self.toolbar.maximumHeight = 100 is not reflecting, the toolbar keep stretching until it go under navigation controller, removing stretching is showing only 2 lines and the textView is small.
    opened by zaidiabbas 2
  • Styling issues

    Styling issues

    [REQUIRED] Step 1: Describe your environment

    • Xcode version: 9.4.1
    • Toolbar version: 0.4.0

    [REQUIRED] Step 3: Describe the problem

    I wan't to be able to have a toolbar with plain background color and remove the transparency effect from the toolbar. I have tried adding background color but its transparent and blurred. I have tried removing the UiVisualEffectView but no luck!

    Steps to reproduce:

    Set backgroundColor of toolbar

    Relevant Code:

    self.toolbar.backgroundColor = UIColor.black.withAlphaComponent(1.0)
    self.toolbar.tintColor = .white
    
    enhancement 
    opened by majid701 1
Owner
1amageek
@1amageek
1amageek
KeyboardKit is a Swift library that helps you create custom keyboard extensions for iOS and ipadOS.

KeyboardKit is a Swift library that helps you create custom keyboard extensions for iOS and ipadOS.

KeyboardKit 900 Jan 9, 2023
iOS utility class allows you to access keyboard view and track keyboard animation.

YYKeyboardManager iOS utility class allows you to access keyboard view and track keyboard animation. (It was used by YYText) Compatibility iPhone / iP

null 480 Nov 17, 2022
KeyboardMan helps you to make keyboard animation.

KeyboardMan We may need keyboard infomation from keyboard notifications to do animation. However, the approach is complicated and easy to make mistake

null 353 Apr 19, 2022
Objective-C library for tracking keyboard in iOS apps.

NgKeyboardTracker Objective-c library for tracking keyboard in iOS apps. Adding to your project If you are using CocoaPods, add to your Podfile: pod '

Meiwin Fu 808 Nov 17, 2022
Codeless drop-in universal library allows to prevent issues of keyboard sliding up and cover UITextField/UITextView. Neither need to write any code nor any setup required and much more.

IQKeyboardManager While developing iOS apps, we often run into issues where the iPhone keyboard slides up and covers the UITextField/UITextView. IQKey

Mohd Iftekhar Qurashi 15.9k Jan 8, 2023
Scribe-iOS is a pack of iOS and iPadOS keyboards for language learners

Scribe-iOS is a pack of iOS and iPadOS keyboards for language learners. Features include translation (beta), verb conjugation and word annotation that give users the tools needed to communicate with confidence.

Scribe 47 Jan 4, 2023
Codeless manager to hide keyboard by tapping on views for iOS written in Swift

KeyboardHideManager KeyboardHideManager - codeless manager to hide keyboard by tapping on views for iOS written in Swift. Structure Features Requireme

Bondar Yaroslav 55 Oct 19, 2022
Swift UIKit keyboard manager for iOS apps.

Typist Typist is a small, drop-in Swift UIKit keyboard manager for iOS apps. It helps you manage keyboard's screen presence and behavior without notif

Toto Tvalavadze 1.1k Dec 10, 2022
Best way to dismiss Keyboard in a View Controller iOS (Swift)

Best way to dismiss Keyboard in a View Controller iOS (Swift) First way: Implement UITextFieldDelegate’s textFieldShouldReturn method and dismiss curr

null 0 Dec 18, 2021
[iOS] Add customized buttons and toolbars to your UITextInputs.

RFKeyboardToolbar This is a flexible UIView and UIButton subclass to add customized buttons and toolbars to your UITextFields/UITextViews. This projec

Rudd Fawcett 421 Oct 30, 2022
A drop-in universal solution for moving text fields out of the way of the keyboard in iOS

TPKeyboardAvoiding A drop-in universal solution for moving text fields out of the way of the keyboard in iOS. Introduction There are a hundred and one

Michael Tyson 5.8k Dec 26, 2022
Emoji Keyboard SDK (iOS)

Makemoji SDK Makemoji is a free emoji keyboard for mobile apps. By installing our keyboard SDK every user of your app will instantly have access to ne

Makemoji 100 Nov 3, 2022
A Chinese keyboard for iOS that helps Chinese language learners remember tones.

ToneBoard ToneBoard is a Chinese keyboard for iOS that requires you to enter the correct tones while typing simplified Chinese with Pinyin. It is avai

Kevin Bell 7 Sep 27, 2022
SwiftyKeyboard: a full customized numeric keyboard for iOS

SwiftyKeyboard Overview SwiftyKeyboard is an iOS customized enhanced keyboard. T

SwiftyKit 2 Jun 30, 2022
Slidden is an open source, customizable, iOS 8 keyboard, written in Swift

Slidden is an open source, customizable, iOS 8 keyboard, written in Swift. iOS 8 brought us the ability to create fully customizable keyboards, but do

Daniel Brim 595 Jan 5, 2023
Emoji Keyboard for iOS

English | 中文 An easy to use Emoji keyboard for iOS. Has been rewritten with swift, the old Objective-C version on branch oc. Features Written in Swift

isaced 450 Dec 24, 2022
Powerful autolayout framework, that can manage UIView(NSView), CALayer and not rendered views. Not Apple Autolayout wrapper. Provides placeholders. Linux support.

CGLayout Powerful autolayout framework, that can manage UIView(NSView), CALayer and not rendered views. Has cross-hierarchy coordinate space. Implemen

Koryttsev Denis 45 Jun 28, 2022
Tip-Calculation- - A program for calculate the tip. You can easily calculate it and you can split money easily

Tip-Calculation- It is a program for calculate the tip. You can easily calculate

Burak Pala 0 Jan 13, 2022
You can easily add awesome animated context menu to your app.

Context-Menu.iOS You can easily add awesome animated context menu to your app. Made in Check this [project on dribbble] (https://dribbble.com/shots/17

Yalantis 1.8k Nov 17, 2022
Full configurable spreadsheet view user interfaces for iOS applications. With this framework, you can easily create complex layouts like schedule, gantt chart or timetable as if you are using Excel.

kishikawakatsumi/SpreadsheetView has moved! It is being actively maintained at bannzai/SpreadsheetView. This fork was created when the project was mov

Kishikawa Katsumi 34 Sep 26, 2022