All Projects → BalestraPatrick → Hapticbutton

BalestraPatrick / Hapticbutton

Licence: mit
A button that is triggered based on the 3D Touch pressure, similar to the iOS 11 control center.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Hapticbutton

Ahdownloadbutton
Customizable download button with progress and transition animations. It is based on Apple's App Store download button.
Stars: ✭ 370 (-26.15%)
Mutual labels:  ios11, button
Pretty
Library for helping print things prettily, in Clojure - ANSI fonts, formatted exceptions
Stars: ✭ 474 (-5.39%)
Mutual labels:  feedback
Managers Playbook
📖 Heuristics for effective management
Stars: ✭ 4,504 (+799%)
Mutual labels:  feedback
Shinebutton
This is a UI lib for Android. Effects like shining.
Stars: ✭ 4,105 (+719.36%)
Mutual labels:  button
Squishbutton
A button that squishes when pressed. As seen in the Clips app.
Stars: ✭ 401 (-19.96%)
Mutual labels:  button
Nfdownloadbutton
Revamped Download Button. It's kinda a reverse engineering of Netflix's app download button.
Stars: ✭ 429 (-14.37%)
Mutual labels:  button
Torch2coreml
Torch7 -> CoreML
Stars: ✭ 363 (-27.54%)
Mutual labels:  ios11
Safariautologintest
A demo showing how you can auto-login users to an iOS app using SafariViewController (on iOS 9) and SFAuthenticationSession (on iOS 11)
Stars: ✭ 480 (-4.19%)
Mutual labels:  ios11
React Native Platform Touchable
A wrapper around the various Touchable* components built into React Native core with platform defaults
Stars: ✭ 440 (-12.18%)
Mutual labels:  button
Onebutton
An Arduino library for using a single button for multiple purpose input.
Stars: ✭ 418 (-16.57%)
Mutual labels:  button
Submitbutton
A submit button with a fun animation for Android.
Stars: ✭ 419 (-16.37%)
Mutual labels:  button
Android Commonshapebutton
To remove all shape files from the project, provide a generic shape style button.
Stars: ✭ 404 (-19.36%)
Mutual labels:  button
Badgebutton
带有徽标(数字,小红点)的按钮
Stars: ✭ 434 (-13.37%)
Mutual labels:  button
Easynavigation
一款超级简单的导航条管理工具。完全自定义导航条。没有UINavigationBar 和 UINavigationItem 这两个类。完全是对UIView的操作。
Stars: ✭ 393 (-21.56%)
Mutual labels:  ios11
Facecropper
✂️ Crop faces, inside of your image, with iOS 11 Vision api.
Stars: ✭ 479 (-4.39%)
Mutual labels:  ios11
Cards
Awesome iOS 11 appstore cards in swift 5.
Stars: ✭ 4,017 (+701.8%)
Mutual labels:  ios11
Haptico
Haptico 📳 - easy to use haptic feedback generator with pattern-play support
Stars: ✭ 426 (-14.97%)
Mutual labels:  feedback
Awesome Coreml Models
Collection of models for Core ML
Stars: ✭ 500 (-0.2%)
Mutual labels:  ios11
Ios Nfc Example
📱 Example showing how to use the Core NFC API in iOS
Stars: ✭ 480 (-4.19%)
Mutual labels:  ios11
Machma
Easy parallel execution of commands with live feedback
Stars: ✭ 438 (-12.57%)
Mutual labels:  feedback

buddybuild Carthage License Platform Twitter: @BalestraPatrick

HapticButton

📖 Description

HapticButton replicates the behavior of the buttons in the iOS 10 and 11 Control Center as well as in the Home app. A device with 3D Touch is required to fully experience the haptic feedback on supported devices. It is implemented as a subclass of UIControl, so feel free to further customize it to your needs.

The user is required to press the button and activate 3D Touch with a minimum pressure threshold (you can specify the minimum value to trigger the button via the feedbackThreshold property). This allows for a cool interaction that gives a haptic feedback to the user when the button is triggered. 👍

For the best experience, install the example on a device. 📱

The example project shows how to set up HapticButton in a few different ways.

  • Create a button with a UILabel. Use the HapticButtonDelegate to be notified when the button is triggered.
@IBOutlet weak var button: HapticButton!
button.mode = .label(text: "Hello! 👋")
// Use the delegate method to be notified when the button is pressed.
button.delegate = self
  • Create a button with a UIImageView and a blur background. Use the standard UIControl event to subscribe to the touch up inside event.
let blurButton = HapticButton(mode: .image(image: #imageLiteral(resourceName: "swift")))
blurButton.addBlurView(style: .light)
// Add custom target selector to the touch up inside event.
blurButton.addTarget(self, action: #selector(blurButtonPressed(_:)), for: .touchUpInside)
  • Create a button with a customized UILabel and dark blur background. Subcribe to the button events through a closure.
let blurButton = HapticButton(mode: .label(text: "Hello Blur!"))
darkBlurButton.textLabel.textColor = .white
darkBlurButton.addBlurView(style: .dark)
// Pass closure to be invoked when the button is pressed.
darkBlurButton.onPressed = {
	print("Dark blur button pressed.")
}

🎨 Customizations

These are the public properties that allow you to customize the control. In case you are thinking to modify HapticButton even further, consider creating a Pull Request! 👏🏻

public weak var delegate: HapticButtonDelegate?

/// The closure invoked when the button is pressed.
public var onPressed: Callback?

/// The minimum pressure that the button press has to receive in order to trigger the related haptic feedback. The value has to be between 0 and 1 and the default is 0.25.
public var feedbackThreshold = 0.25

/// If the button is in mode `label`, this `UILabel` is part of the button hierarchy. Modify this object directly for more customizations on the displayed text.
public lazy var textLabel: UILabel

/// If the button is in mode `image`, this `UIImageView` is part of the button hierarchy. Modify this object directly for more customizations on the displayed image.
public lazy var imageView: UIImageView

/// The current mode of the button.
public var mode = HapticButtonMode.label(text: "Title")

🔞 Requirements

iOS 10.0 and Swift 3.2 are required.

If you are using Swift 4, please use the swift4 branch.

🛠 Installation

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

pod "HapticButton"

You can also use Carthage if you prefer. Add this line to your Cartfile.

github "BalestraPatrick/HapticButton"

👨‍💻 Author

I'm Patrick Balestra.

Email: [email protected]

Twitter: @BalestraPatrick.

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].