FBTooltipView.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * Copyright 2010-present Facebook.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <UIKit/UIKit.h>
  17. /*!
  18. @typedef FBTooltipViewArrowDirection enum
  19. @abstract
  20. Passed on construction to determine arrow orientation.
  21. */
  22. typedef NS_ENUM(NSUInteger, FBTooltipViewArrowDirection) {
  23. /*! View is located above given point, arrow is pointing down. */
  24. FBTooltipViewArrowDirectionDown = 0,
  25. /*! View is located below given point, arrow is pointing up. */
  26. FBTooltipViewArrowDirectionUp = 1,
  27. };
  28. /*!
  29. @typedef FBTooltipColorStyle enum
  30. @abstract
  31. Passed on construction to determine color styling.
  32. */
  33. typedef NS_ENUM(NSUInteger, FBTooltipColorStyle) {
  34. /*! Light blue background, white text, faded blue close button. */
  35. FBTooltipColorStyleFriendlyBlue = 0,
  36. /*! Dark gray background, white text, light gray close button. */
  37. FBTooltipColorStyleNeutralGray = 1,
  38. };
  39. /*!
  40. @class FBTooltipView
  41. @abstract
  42. Tooltip bubble with text in it used to display tips for UI elements,
  43. with a pointed arrow (to refer to the UI element).
  44. @discussion
  45. The tooltip fades in and will automatically fade out. See `displayDuration`.
  46. */
  47. @interface FBTooltipView : UIView
  48. /*!
  49. @abstract Gets or sets the amount of time in seconds the tooltip should be displayed.
  50. @discussion Set this to zero to make the display permanent until explicitly dismissed.
  51. Defaults to six seconds.
  52. */
  53. @property (nonatomic, assign) CFTimeInterval displayDuration;
  54. /*!
  55. @abstract Gets or sets the color style after initialization.
  56. @discussion Defaults to value passed to -initWithTagline:message:colorStyle:.
  57. */
  58. @property (nonatomic, assign) FBTooltipColorStyle colorStyle;
  59. /*!
  60. @abstract Gets or sets the message.
  61. */
  62. @property (nonatomic, copy) NSString *message;
  63. /*!
  64. @abstract Gets or sets the optional phrase that comprises the first part of the label (and is highlighted differently).
  65. */
  66. @property (nonatomic, copy) NSString *tagline;
  67. /*!
  68. @abstract
  69. Designated initializer.
  70. @param tagline First part of the label, that will be highlighted with different color. Can be nil.
  71. @param message Main message to display.
  72. @param colorStyle Color style to use for tooltip.
  73. @discussion
  74. If you need to show a tooltip for login, consider using the `FBLoginTooltipView` view.
  75. @see FBLoginTooltipView
  76. */
  77. - (id)initWithTagline:(NSString *)tagline message:(NSString *)message colorStyle:(FBTooltipColorStyle)colorStyle;
  78. /*!
  79. @abstract
  80. Show tooltip at the top or at the bottom of given view.
  81. Tooltip will be added to anchorView.window.rootViewController.view
  82. @param anchorView view to show at, must be already added to window view hierarchy, in order to decide
  83. where tooltip will be shown. (If there's not enough space at the top of the anchorView in window bounds -
  84. tooltip will be shown at the bottom of it)
  85. @discussion
  86. Use this method to present the tooltip with automatic positioning or
  87. use -presentInView:withArrowPosition:direction: for manual positioning
  88. If anchorView is nil or has no window - this method does nothing.
  89. */
  90. - (void)presentFromView:(UIView *)anchorView;
  91. /*!
  92. @abstract
  93. Adds tooltip to given view, with given position and arrow direction.
  94. @param view View to be used as superview.
  95. @param arrowPosition Point in view's cordinates, where arrow will be pointing
  96. @param arrowDirection whenever arrow should be pointing up (message bubble is below the arrow) or
  97. down (message bubble is above the arrow).
  98. */
  99. - (void)presentInView:(UIView *)view withArrowPosition:(CGPoint)arrowPosition direction:(FBTooltipViewArrowDirection)arrowDirection;
  100. /*!
  101. @abstract
  102. Remove tooltip manually.
  103. @discussion
  104. Calling this method isn't necessary - tooltip will dismiss itself automatically after the `displayDuration`.
  105. */
  106. - (void)dismiss;
  107. @end