EAIntroView.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. //
  2. // EAIntroView.h
  3. //
  4. // Copyright (c) 2013-2015 Evgeny Aleksandrov. License: MIT.
  5. #import <UIKit/UIKit.h>
  6. #import <EARestrictedScrollView/EARestrictedScrollView.h>
  7. #import "EAIntroPage.h"
  8. #define EA_EMPTY_PROPERTY 9999.f
  9. #define SKIP_BTN_DEFAULT_WIDTH 100.f
  10. #define SKIP_BTN_DEFAULT_HEIGHT 40.f
  11. #define PAGE_CTRL_DEFAULT_HEIGHT 36.f
  12. enum EAIntroViewTags {
  13. kTitleLabelTag = 1,
  14. kDescLabelTag,
  15. kTitleImageViewTag
  16. };
  17. typedef NS_ENUM(NSUInteger, EAViewAlignment) {
  18. EAViewAlignmentLeft,
  19. EAViewAlignmentCenter,
  20. EAViewAlignmentRight,
  21. };
  22. @class EAIntroView;
  23. @protocol EAIntroDelegate<NSObject>
  24. @optional
  25. - (void)introWillFinish:(EAIntroView *)introView wasSkipped:(BOOL)wasSkipped;
  26. - (void)introDidFinish:(EAIntroView *)introView wasSkipped:(BOOL)wasSkipped;
  27. - (void)intro:(EAIntroView *)introView pageAppeared:(EAIntroPage *)page withIndex:(NSUInteger)pageIndex;
  28. - (void)intro:(EAIntroView *)introView pageStartScrolling:(EAIntroPage *)page withIndex:(NSUInteger)pageIndex;
  29. - (void)intro:(EAIntroView *)introView pageEndScrolling:(EAIntroPage *)page withIndex:(NSUInteger)pageIndex;
  30. // Called for every incremental scroll event.
  31. // Parameter offset is some fraction of the currentPageIndex, between currentPageIndex-1 and currentPageIndex+1
  32. // For example, scrolling left and right from page 2 will values in the range [1..3], exclusive
  33. - (void)intro:(EAIntroView *)introView didScrollWithOffset:(CGFloat)offset;
  34. @end
  35. @interface EAIntroView : UIView <UIScrollViewDelegate>
  36. @property (nonatomic, weak) id<EAIntroDelegate> delegate;
  37. @property (nonatomic, assign) BOOL swipeToExit;
  38. @property (nonatomic, assign) BOOL tapToNext;
  39. @property (nonatomic, assign) BOOL hideOffscreenPages;
  40. @property (nonatomic, assign) BOOL easeOutCrossDisolves;
  41. @property (nonatomic, assign) BOOL useMotionEffects;
  42. @property (nonatomic, assign) CGFloat motionEffectsRelativeValue;
  43. // Title View (Y position - from top of the screen)
  44. @property (nonatomic, strong) UIView *titleView;
  45. @property (nonatomic, assign) CGFloat titleViewY;
  46. // Background image
  47. @property (nonatomic, strong) UIImage *bgImage;
  48. @property (nonatomic, assign) UIViewContentMode bgViewContentMode;
  49. // Page Control (Y position - from bottom of the screen)
  50. @property (nonatomic, strong) UIPageControl *pageControl;
  51. @property (nonatomic, assign) CGFloat pageControlY;
  52. @property (nonatomic, assign) NSUInteger currentPageIndex;
  53. @property (nonatomic, assign, readonly) NSUInteger visiblePageIndex;
  54. // Skip button (Y position - from bottom of the screen)
  55. @property (nonatomic, strong) UIButton *skipButton;
  56. @property (nonatomic, assign) CGFloat skipButtonY;
  57. @property (nonatomic, assign) CGFloat skipButtonSideMargin;
  58. @property (nonatomic, assign) EAViewAlignment skipButtonAlignment;
  59. @property (nonatomic, assign) BOOL showSkipButtonOnlyOnLastPage;
  60. @property (nonatomic, assign) NSInteger limitPageIndex;
  61. @property (nonatomic, strong) EARestrictedScrollView *scrollView;
  62. @property (nonatomic, assign) BOOL scrollingEnabled;
  63. @property (nonatomic, strong) NSArray<EAIntroPage *> *pages;
  64. - (id)initWithFrame:(CGRect)frame andPages:(NSArray<EAIntroPage *> *)pagesArray;
  65. - (void)showFullscreen;
  66. - (void)showFullscreenWithAnimateDuration:(CGFloat)duration;
  67. - (void)showFullscreenWithAnimateDuration:(CGFloat)duration andInitialPageIndex:(NSUInteger)initialPageIndex;
  68. - (void)showInView:(UIView *)view;
  69. - (void)showInView:(UIView *)view animateDuration:(CGFloat)duration;
  70. - (void)showInView:(UIView *)view animateDuration:(CGFloat)duration withInitialPageIndex:(NSUInteger)initialPageIndex;
  71. - (void)hideWithFadeOutDuration:(CGFloat)duration;
  72. - (void)setCurrentPageIndex:(NSUInteger)currentPageIndex;
  73. - (void)setCurrentPageIndex:(NSUInteger)currentPageIndex animated:(BOOL)animated;
  74. - (void)scrollToPageForIndex:(NSUInteger)newPageIndex animated:(BOOL)animated;
  75. @end