iphone开发之仿微信用户引导界面的实现

出于用户体验大多数应用在应用首次启动时,显示一个简单的介绍页面也就是用户引导页面,如下效果:

iphone开发之仿微信用户引导界面的实现_第1张图片

自己也试着尝试了一下,主要是使用scrollview实现视图的切换,当切换到最后一张时会出现一个开始按钮,点击开始按钮关闭引导。

开始按钮点击处理:

- (IBAction)startButtonDidPressed:(id)sender{
    [self.startButton setHidden:YES];
    NSArray *array = [UIImage splitImageIntoTwoParts:self.imageView.image];
    self.left = [[UIImageView alloc] initWithImage:[array objectAtIndex:0]];
    float height = DEVICE_IS_IPHONE5 ? 568 : 480;
    [self.left setFrame:CGRectMake(0, 0, 320, height)];
    self.right = [[UIImageView alloc] initWithImage:[array objectAtIndex:1]];
    [self.right setFrame:CGRectMake(0, 0, 320, height)];
    
    [self addSubview:self.left];
    [self addSubview:self.right];
    [self.pageScroll setHidden:YES];
    [self.pageControl setHidden:YES];
    self.left.transform = CGAffineTransformIdentity;
    self.right.transform = CGAffineTransformIdentity;
    
    [UIView beginAnimations:@"split" context:nil];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDuration:1.2];
    [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
    
    [self.left setAlpha:0.15];
    [self.right setAlpha:0.15];
    self.left.transform = CGAffineTransformMakeTranslation(-180 ,0);
    self.right.transform = CGAffineTransformMakeTranslation(180 ,0);   
    [UIView commitAnimations];
}


将最后一张图片切割成两部分,添加一个“开门的动画”,动画结束时移除图片:

-(void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
{   
    [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
    if ([animationID isEqualToString:@"split"] && finished) {
        [self.left removeFromSuperview];
        [self.right removeFromSuperview];
    }
    [self removeFromSuperview];
}


说明:splitImageIntoTwoParts (Terry Lin 实现)是实现了UIImage的分类,将图片分割成两部分。

工程源码地址:UserGuide



你可能感兴趣的:(ios,iPhone)