引导页总结

Page类

继承于NSObject,保存每个page的信息,如各种图片、文字、标题内容等。

@interface EAIntroPage : NSObject

// title image Y position - from top of the screen
// title and description labels Y position - from bottom of the screen
@property (nonatomic, retain) UIImage *bgImage;
@property (nonatomic, retain) UIImage *titleImage;
@property (nonatomic, assign) CGFloat imgPositionY;
@property (nonatomic, retain) NSString *title;
@property (nonatomic, retain) UIFont *titleFont;
@property (nonatomic, retain) UIColor *titleColor;
@property (nonatomic, assign) CGFloat titlePositionY;
@property (nonatomic, retain) NSString *desc;
@property (nonatomic, retain) UIFont *descFont;
@property (nonatomic, retain) UIColor *descColor;
@property (nonatomic, assign) CGFloat descPositionY;

// if customView is set - all other properties are ignored
@property (nonatomic, retain) UIView *customView;

+ (EAIntroPage *)page;
+ (EAIntroPage *)pageWithCustomView:(UIView *)customV;

@end

 

View类的subViews

1.UIImageView *bgImageView

最底层,背景图片,初始化为clearColor。

    self.bgImageView = [[UIImageView alloc] initWithFrame:self.frame];
    self.bgImageView.backgroundColor = [UIColor clearColor];
    self.bgImageView.contentMode = UIViewContentModeScaleToFill;
    self.bgImageView.autoresizesSubviews = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
    self.bgImageView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
    [self addSubview:self.bgImageView];

如果不需要修改每个page的背景图片,每个page使用相同的背景图片,则只需要设置此VIEW的image,不需要设置pageBgBack和PageBgFront。

 

2.UIImageView *pageBgFront,pageBgBack

初始化同上。front在上,back在下,分别代表当前page的背景和下一page的背景,。初始化时候分别为0页和1页。

这两个imageView位置不变,始终显示在当前屏幕上,在页面切换的时候调整它们的alpha值,达到背景平滑切换的效果。

如果背景为纯色,则背景颜色平滑过度到目标颜色;如果背景为图片,则上面的图片渐渐隐藏的同时下面的图片渐渐显现。

    [self.pageBgFront setAlpha:1];
    [self.pageBgFront setImage:[self bgForPage:page]];
    [self.pageBgBack setAlpha:0];
    [self.pageBgBack setImage:[self bgForPage:page+1]];
    
    float backLayerAlpha = alphaValue;
    float frontLayerAlpha = (1 - alphaValue);
    
    [self.pageBgBack setAlpha:backLayerAlpha];
    [self.pageBgFront setAlpha:frontLayerAlpha];

 其中,page的值为:

float offset = scrollView.contentOffset.x / self.scrollView.frame.size.width;

 

 

3.UIScrollView *scrollView  NSMutableArray *pageViews

 

4.UIView *titleView;
 

 

posted on 2014-09-29 19:23  嘉遁  阅读(261)  评论(0编辑  收藏  举报

导航