EAIntroPage.m 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //
  2. // EAIntroPage.m
  3. //
  4. // Copyright (c) 2013-2015 Evgeny Aleksandrov. License: MIT.
  5. #import "EAIntroPage.h"
  6. #define DEFAULT_DESCRIPTION_LABEL_SIDE_PADDING 25
  7. #define DEFAULT_TITLE_FONT [UIFont fontWithName:@"HelveticaNeue-Bold" size:16.0]
  8. #define DEFAULT_LABEL_COLOR [UIColor whiteColor]
  9. #define DEFAULT_BG_COLOR [UIColor clearColor]
  10. #define DEFAULT_DESCRIPTION_FONT [UIFont fontWithName:@"HelveticaNeue-Light" size:13.0]
  11. #define DEFAULT_TITLE_IMAGE_Y_POSITION 50.0f
  12. #define DEFAULT_TITLE_LABEL_Y_POSITION 160.0f
  13. #define DEFAULT_DESCRIPTION_LABEL_Y_POSITION 140.0f
  14. #define DEFAULT_DESCRIPTION_LABEL_SIDE_MARGIN 10.0f
  15. @interface EAIntroPage ()
  16. @property(nonatomic, strong, readwrite) UIView *pageView;
  17. @end
  18. @implementation EAIntroPage
  19. #pragma mark - Page lifecycle
  20. - (instancetype)init {
  21. if (self = [super init]) {
  22. _titleIconPositionY = DEFAULT_TITLE_IMAGE_Y_POSITION;
  23. _titlePositionY = DEFAULT_TITLE_LABEL_Y_POSITION;
  24. _descPositionY = DEFAULT_DESCRIPTION_LABEL_Y_POSITION;
  25. _descSideMargin = DEFAULT_DESCRIPTION_LABEL_SIDE_MARGIN;
  26. _title = @"";
  27. _titleFont = DEFAULT_TITLE_FONT;
  28. _titleColor = DEFAULT_LABEL_COLOR;
  29. _titleAlignment = NSTextAlignmentCenter;
  30. _desc = @"";
  31. _descFont = DEFAULT_DESCRIPTION_FONT;
  32. _descColor = DEFAULT_LABEL_COLOR;
  33. _descAlignment = NSTextAlignmentCenter;
  34. _bgColor = DEFAULT_BG_COLOR;
  35. _showTitleView = YES;
  36. _alpha = 1.f;
  37. }
  38. return self;
  39. }
  40. + (instancetype)page {
  41. return [[self alloc] init];
  42. }
  43. + (instancetype)pageWithCustomView:(UIView *)customV {
  44. EAIntroPage *newPage = [[self alloc] init];
  45. newPage.customView = customV;
  46. newPage.customView.translatesAutoresizingMaskIntoConstraints = NO;
  47. newPage.bgColor = customV.backgroundColor;
  48. return newPage;
  49. }
  50. + (instancetype)pageWithCustomViewFromNibNamed:(NSString *)nibName {
  51. return [self pageWithCustomViewFromNibNamed:nibName bundle:[NSBundle mainBundle]];
  52. }
  53. + (instancetype)pageWithCustomViewFromNibNamed:(NSString *)nibName bundle:(NSBundle*)aBundle {
  54. EAIntroPage *newPage = [[self alloc] init];
  55. newPage.customView = [[aBundle loadNibNamed:nibName owner:newPage options:nil] firstObject];
  56. newPage.customView.translatesAutoresizingMaskIntoConstraints = NO;
  57. newPage.bgColor = newPage.customView.backgroundColor;
  58. return newPage;
  59. }
  60. @end