Search code examples
iosiphoneswiftios8tooltip

iOS call to action tooltip component


I am looking for a robust tooltip component written in Swift that would allow me to display instructions or "call to action" messages at certain moments. After researching I found several components but they either lack some of the functionalities I need or they don't seem so sturdy to me. The component should:

  • Support device orientation changes
  • Provide a delegate so I should know if the user dismissed the tooltip
  • Be flexible and easy customizable
  • Integration with Cocoapods would be a plus

Thanks!


Solution

  • I recommend you to take a look at EasyTipView.

    EasyTipView is a custom tooltip view written in Swift that can be used as a call to action or informative tip. It can be presented for any UIBarButtonItem or UIView subclass. In addition it handles automatically orientation changes and will always point to the correct view or item.

    To integrate EasyTipView into your Xcode project using CocoaPods, specify it in your Podfile:

    source 'https://github.com/CocoaPods/Specs.git'
    platform :ios, '8.0'
    use_frameworks!
    
    pod 'EasyTipView', '~> 0.1.0'
    

    Usage:

    1) First you should customize the preferences:

    var preferences = EasyTipView.Preferences()
    preferences.bubbleColor = UIColor(hue:0.58, saturation:0.1, brightness:1, alpha:1)
    preferences.textColor = UIColor.darkGrayColor()
    preferences.font = UIFont(name: "HelveticaNeue-Regular", size: 10)
    preferences.textAlignment = NSTextAlignment.Center
    

    2) Secondly you call the showAnimated:forView:withinSuperview:text:preferences:delegate: method:

    EasyTipView.showAnimated(true, 
    forView: self.buttonB, 
    withinSuperview: self.navigationController?.view,
    text: "Tip view inside the navigation controller's view. Tap to  dismiss!",
    preferences: preferences,
    delegate: self)
    

    The EasyTipViewDelegate protocol defines one method to be called on the delegate after the EasyTipView has been dismissed.