Skip to content

c2mInc/WobbingButton

Repository files navigation

WobbingButton

UIButton is not enough. Replace it with a lightweight control, the WobbingButton.

WobbingButton is a subclass of UIControl, it is a hassle free, storyboard friendly UI component. You could set corner radius directly from storyboard as well as wobble scale, handle target functions as closures, drag drop nested components. Unchain the limits of UIButton.

WobbingButton: A lightweight storyboard friendly UIButton replacement.

Example

Try it!

pod try 'WobbingButton'

This will open up an example project which you'll have a quick insight about the library.

Installation

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

pod 'WobbingButton'

Alternatively drag and drop WobbingButton.swift file into your project.

WobbingButton

WobbingButton is a UIControl subclass.

RoundedWobbingButton

RoundedWobbingButton is a WobbingButton subclass, it has rounded left and right corners.

WobbingIcon

WobbingIcon is too a WobbingButton subclass, it is best used with monochrome icons, set tintColor in storyboard.

RoundedWobbingIcon

RoundedWobbingIcon is a WobbingIcon subclass and it is like a rounded version of WobbingIcon.

Basic Usage

Drag a UIView into a viewcontroller, change its class type to WobbingButton, RoundedWobbingButton, WobbingIcon or RoundedWobbingIcon. Add a background color, you are set, start wobbling.

Sometimes it's quite useful to assign closures rather than adding target to methods. WobbingButton provides onTapAction and onLongPressAction closures to handle those actions gracefully. In addition to touch events like .touchUpInside, .touchDown, it works with tap and long press closures as well.

let wobbingButton = WobbingButton(frame: ...)
wobbingButton.onTapAction = { [weak self] in
  //  self?.wobbingButtonTapped()
}

Even long presses.

let wobbingButton = WobbingButton(frame: ...)
wobbingButton.onLongPressAction = { [weak self] in
  //  self?.wobbingButtonLongPressed()
}

Requirements

  • iOS 10.0+
  • Xcode 8.0+
  • Swift 4.0+

Author

Connected2.me / Erk Ekin @erkekin

Awesome logo: @berilKarabulut

License

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

Copyright (c) 2018 erkekin erkekin@gmail.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.