AWFCalloutView

Objective-C

@interface AWFCalloutView : UIView

Swift

class AWFCalloutView : UIView

AWFCalloutView is a lightweight callout view that mimic’s the native UICalloutView in iOS that offers greater flexibility and supports being used outside of MapKit.

  • The title for the callout.

    Declaration

    Objective-C

    @property (nonatomic, copy) NSString *title;

    Swift

    var title: String! { get set }
  • The subtitle for the callout.

    Declaration

    Objective-C

    @property (nonatomic, copy) NSString *subtitle;

    Swift

    var subtitle: String! { get set }
  • The view to display on the left side of the callout view.

    Declaration

    Objective-C

    @property (nonatomic, strong) UIView *leftAccessoryView;

    Swift

    var leftAccessoryView: UIView! { get set }
  • The view to display on the right side of the callout view.

    Declaration

    Objective-C

    @property (nonatomic, strong) UIView *rightAccessoryView;

    Swift

    var rightAccessoryView: UIView! { get set }
  • The arrow directions that are permitted when presenting a callout view. The default value is AWFCalloutArrowDirectionDown.

    Declaration

    Objective-C

    @property (nonatomic) AWFCalloutArrowDirection permittedArrowDirection;

    Swift

    var permittedArrowDirection: AWFCalloutArrowDirection { get set }
  • The current arrow direction used for the callout view.

    Declaration

    Objective-C

    @property (nonatomic, readonly) AWFCalloutArrowDirection currentArrowDirection;

    Swift

    var currentArrowDirection: AWFCalloutArrowDirection { get }
  • The insets to apply to the constrained view’s bounds, specifically if the specified constrained view has portions that are overlapped by a navigation bar, tab bar or other navigation element.

    Declaration

    Objective-C

    @property (nonatomic) UIEdgeInsets constrainedInsets;

    Swift

    var constrainedInsets: UIEdgeInsets { get set }
  • The receiver’s delegate.

    A callout view sends messages to its delegate regarding the presentation and dismissal of a callout view.

    Declaration

    Objective-C

    @property (nonatomic, weak) id<AWFCalloutViewDelegate> delegate;

    Swift

    weak var delegate: AWFCalloutViewDelegate! { get set }
  • The view to display for the title.

    If this property is set, then title will be ignored.

    Note

    Keep in mind that AWFCalloutView calls sizeThatFits on this view if provided, so your view may be resized as a result, especially for UILabel and UITextField. You may want to subclass and override sizeThatFits, or just wrap your view in a generic UIView if you do not want it to be auto-sized.

    Declaration

    Objective-C

    @property (nonatomic, strong) UIView *titleView;

    Swift

    var titleView: UIView! { get set }
  • The view to display for the subtitle.

    If this property is set, then subtitle will be ignored.

    Note

    Keep in mind that AWFCalloutView calls sizeThatFits on this view if provided, so your view may be resized as a result, especially for UILabel and UITextField. You may want to subclass and override sizeThatFits, or just wrap your view in a generic UIView if you do not want it to be auto-sized.

    Declaration

    Objective-C

    @property (nonatomic, strong) UIView *subtitleView;

    Swift

    var subtitleView: UIView! { get set }
  • The custom content view that can be any width and/or height.

    If this property is set, then title, subtitle, titleView, and subtitleView are all ignored.

    Declaration

    Objective-C

    @property (nonatomic, strong) UIView *contentView;

    Swift

    var contentView: UIView! { get set }
  • The custom content view margin.

    Declaration

    Objective-C

    @property (nonatomic) UIEdgeInsets contentViewInset;

    Swift

    var contentViewInset: UIEdgeInsets { get set }
  • The offset in screen points from the top-middle of the annotation view where the anchor of the callout should be drawn.

    Declaration

    Objective-C

    @property (nonatomic) CGPoint calloutOffset;

    Swift

    var calloutOffset: CGPoint { get set }
  • The animation style to use when presenting the callout view. The default is AWFCalloutAnimationBounce.

    Declaration

    Objective-C

    @property (nonatomic) AWFCalloutAnimation presentAnimation;

    Swift

    var presentAnimation: AWFCalloutAnimation { get set }
  • The animation style to use when dismissing the callout view. The default is AWFCalloutAnimationFade.

    Declaration

    Objective-C

    @property (nonatomic) AWFCalloutAnimation dismissAnimation;

    Swift

    var dismissAnimation: AWFCalloutAnimation { get set }
  • Returns a new instance of AWFCalloutView that mimics the platform’s native callout style.

    Declaration

    Objective-C

    + (AWFCalloutView *)platformCalloutView;

    Swift

    class func platform() -> AWFCalloutView!
  • Presents a callout view by adding it to the specified inView and pointing at the given rect of inView‘s bounds.

    The callout is constrained to the bounds of the given view. This method optionally scrolls the given rect into view (plus margins) if delegate is set and responds to delayForRepositionWithSize:.

    Declaration

    Objective-C

    - (void)presentCalloutFromRect:(CGRect)rect
                            inView:(UIView *)view
                 constrainedToView:(UIView *)constrainedView
                          animated:(BOOL)animated;

    Swift

    func presentCallout(from rect: CGRect, in view: UIView!, constrainedTo constrainedView: UIView!, animated: Bool)

    Parameters

    rect

    The rect at which the callout points.

    view

    The view in which to add the callout view.

    constrainedView

    The view whose bounds are used to constrain the callout view.

    animated

    YES if the presentation should be animated, otherwise NO.

  • Presents a callout view by adding it to the specified layer and pointing at the given rect of the layer’s bounds.

    The callout is constrained to the bounds of the given layer. This method optionally scrolls the given rect into view (plus margins) if delegate is set and responds to delayForRepositionWithSize:.

    Note

    Be aware that you’ll have to direct your own touches to any accessory views presenting within a layer since CALayer doesn’t relay touch events.

    Declaration

    Objective-C

    - (void)presentCalloutFromRect:(CGRect)rect
                           inLayer:(CALayer *)layer
                constrainedToLayer:(CALayer *)constrainedLayer
                          animated:(BOOL)animated;

    Swift

    func presentCallout(from rect: CGRect, in layer: CALayer!, constrainedTo constrainedLayer: CALayer!, animated: Bool)

    Parameters

    rect

    The rect at which the callout points.

    layer

    The layer in which to add the callout view.

    constrainedLayer

    The layer whose bounds are used to constrain the callout view.

    animated

    YES if the presentation should be animated, otherwise NO.

  • Updates the callout position by providing a new target rect and view.

    Declaration

    Objective-C

    - (void)moveCalloutToRect:(CGRect)rect
                       inView:(UIView *)view
            constrainedToView:(UIView *)constrainedView;

    Swift

    func moveCallout(to rect: CGRect, in view: UIView!, constrainedTo constrainedView: UIView!)

    Parameters

    rect

    The rect to move the callout to

    view

    The view in which the callout will appear

    constrainedView

    The view in which the callout should be constrained to

  • Updates the callout position by providing a new target rect and layer.

    Declaration

    Objective-C

    - (void)moveCalloutToRect:(CGRect)rect
                      inLayer:(CALayer *)layer
           constrainedToLayer:(CALayer *)constrainedLayer;

    Swift

    func moveCallout(to rect: CGRect, in layer: CALayer!, constrainedTo constrainedLayer: CALayer!)

    Parameters

    rect

    The rect to move the callout to

    layer

    The layer in which the callout will appear

    constrainedLayer

    The layer in which the callout will be constrained to

  • Dismisses the callout.

    Declaration

    Objective-C

    - (void)dismissCalloutAnimated:(BOOL)animated;

    Swift

    func dismissCallout(animated: Bool)

    Parameters

    animated

    A Boolean indicating if the dismissal should be animated using a fade out effect.

  • Updates the callout’s layout and size by recalculating the size needed for its subviews, specifically when changing the contentView bounds.

    Declaration

    Objective-C

    - (void)updateLayoutAnimated:(BOOL)animated;

    Swift

    func updateLayout(animated: Bool)

    Parameters

    animated

    A Boolean indicating whether the layout change should be animated

  • When subclassing AWFCalloutView, this method allows you to return a custom animation to use when presenting and/or dismissing the callout.

    Declaration

    Objective-C

    - (CAAnimation *)animationWithType:(AWFCalloutAnimation)type
                            presenting:(BOOL)presenting;

    Swift

    func animation(withType type: AWFCalloutAnimation, presenting: Bool) -> CAAnimation!

    Parameters

    type

    The animation type.

    presenting

    A Boolean value indicating whether the callout is being presented, YES, or dismissed, NO.

    Return Value

    The animation to use for the action.