Coder Social home page Coder Social logo

easytipview's Introduction

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.

easytipview's People

Contributors

teodorpatras avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.