注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

熊猫正正的博客

熊猫正正的天空

 
 
 

日志

 
 

iphone开发-pagecontrol控制使用  

2013-07-02 22:43:12|  分类: iphone sdk |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

#import <UIKit/UIKit.h>


@interface ViewController : UIViewController

{

    IBOutlet UIPageControl *pageControl;

    IBOutlet UIImageView *imageView1;

    IBOutlet UIImageView *imageView2;

    

    UIImageView *tempImageView,*bgImageView;

}


@property (nonatomic,strong) UIPageControl *pageControl;

@property (nonatomic,strong) UIImageView *imageView1;

@property (nonatomic,strong) UIImageView *imageView2;


@end


---------------------------

#import "ViewController.h"


@interface ViewController ()


@end


@implementation ViewController


@synthesize pageControl;

@synthesize imageView1,imageView2;


- (void)viewDidLoad

{

    [super viewDidLoad];

// Do any additional setup after loading the view, typically from a nib.

    [imageView1 setImage:[UIImage imageNamed:@"iMac_old.jpeg"]];

    tempImageView = imageView2;

    [pageControl addTarget:self action:@selector(pageTurning:) forControlEvents:UIControlEventValueChanged];

}


- (void) pageTurning: (UIPageControl*) pageController

{

    NSInteger nextPage = [pageControl currentPage];

    switch (nextPage) {

        case 0:

            [tempImageView setImage:[UIImage imageNamed:@"iMac_old.jpeg"]];

            break;

        case 1:

            [tempImageView setImage:[UIImage imageNamed:@"iMac.jpeg"]];

            break;

        case 2:

            [tempImageView setImage:[UIImage imageNamed:@"Mac8100.jpeg"]];

            break;

        case 3:

            [tempImageView setImage:[UIImage imageNamed:@"MacPlus.jpg"]];

            break;

        case 4:

            [tempImageView setImage:[UIImage imageNamed:@"MacSE.jpeg"]];

            break;

        default:

            break;

    }

    

    if (tempImageView.tag == 0)

    {

        tempImageView = imageView2;

        bgImageView = imageView1;

    }

    else

    {

        tempImageView = imageView1;

        bgImageView = imageView2;

    }

    

    [UIView beginAnimations:@"flipping view" context:nil];

    [UIView setAnimationDuration:0.5];

    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:tempImageView cache:YES];

    

    [tempImageView setHidden:YES];

    [UIView commitAnimations];

    

    [UIView beginAnimations:@"flpping view" context:nil];

    [UIView setAnimationDuration:0.5];

    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:bgImageView cache:YES];

    [bgImageView setHidden:NO];

    [UIView commitAnimations];

}


- (void)didReceiveMemoryWarning

{

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}


@end


  评论这张
 
阅读(35)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017