A tooltip view written in Swift.
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 1 commit ahead, 67 commits behind teodorpatras:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
EasyTipView
Example
images
.gitignore
EasyTipView.podspec
LICENSE
README.md

README.md

EasyTipView

Purpose

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.

Example

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
  
  1. 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)

Supported OS & SDK Versions

  • Supported build target - iOS 7.0 (Xcode 6.x)

Custom types

@objc protocol EasyTipViewDelegate {
    func easyTipViewDidDismiss(tipView : EasyTipView)
}

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

struct Preferences {
  var systemFontSize          :   CGFloat                =   15
  var textColor               :   UIColor                =   UIColor.whiteColor()
  var bubbleColor             :   UIColor                =   UIColor.redColor()
  var arrowPosition           :   ArrowPosition          =   .Bottom
  var font                    :   UIFont?
  var textAlignment           :   NSTextAlignment        =   NSTextAlignment.Center
}

Custom structure which encapsulates all the customizable properties of the EasyTipView. If the font is not specified, the tip view will default to the UIFont.systemFontOfSize(preferences.systemFontSize).

enum ArrowPosition {
  case Top
  case Bottom
}

Custom enumeration which defines the position that the bubble arrow can take.

Methods

class func showAnimated(animated : Bool, forView view : UIView, withinSuperview superview : UIView?, text :  NSString, preferences: Preferences?, delegate : EasyTipViewDelegate?)

Call this class method when you want to display the EasyTipView pointing to a UIView subclass. superview parameter is optional. If you do not specify a superview, the EasyTipView will be displayed within the main window.

func showForView(view : UIView, withinSuperview sview : UIView?, animated : Bool)

The same as the above method, only difference is that this is an instance method.

class func showAnimated(animated : Bool, forItem item : UIBarButtonItem, withinSuperview superview : UIView?, text : NSString, preferences: Preferences?, delegate : EasyTipViewDelegate?)

Call this class method when you want to display the EasyTipView pointing to a UIBarButtonItem subclass. superview parameter is optional. If you do not specify a superview, the EasyTipView will be displayed within the main window.

func showForItem(item : UIBarButtonItem, withinSuperView sview : UIView?, animated : Bool)

The same as the above method, only difference is that this is an instance method.

func dismissWithCompletion(completion : ((finished : Bool) -> Void)?)

Use this method to programmatically hide the EasyTipView view.