只有第一次運行程式才出現 ,刪除重新運行程式才會有。 我只展示最後一張圖了。 首先創建一個viewcontroller的類 然後在APPDelegate中設為根視圖 然後在 UseGuideViewController.h中寫 FirstViewController是我的主界面。 巨集定義寬和高 下麵
只有第一次運行程式才出現 ,刪除重新運行程式才會有。
我只展示最後一張圖了。
首先創建一個viewcontroller的類
然後在APPDelegate中設為根視圖
然後在
UseGuideViewController.h中寫
FirstViewController是我的主界面。
巨集定義寬和高
#import <UIKit/UIKit.h> #import "FirstViewController.h" #define WIDTH self.view.frame.size.width #define HEIGHT self.view.frame.size.height @interface UseGuideViewController : UIViewController<UIScrollViewDelegate> @end
下麵的就是UseGuideViewController.m中的代碼 ,有一些註釋。
#import "UseGuideViewController.h" @interface UseGuideViewController () @end @implementation UseGuideViewController - (void)viewDidLoad { [super viewDidLoad]; [self initGuide]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } -(void)initGuide { UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)]; [scrollView setContentSize:CGSizeMake(WIDTH*4, 0)]; [scrollView setPagingEnabled:YES]; //視圖整頁顯示 // [scrollView setBounces:NO]; //避免彈跳效果,避免把根視圖露出來 scrollView.delegate=self; UIImageView *imageview = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)]; [imageview setImage:[UIImage imageNamed:@"5.png"]]; [scrollView addSubview:imageview]; UIImageView *imageview1 = [[UIImageView alloc] initWithFrame:CGRectMake(WIDTH, 0, WIDTH, HEIGHT)]; [imageview1 setImage:[UIImage imageNamed:@"004.png"]]; [scrollView addSubview:imageview1]; UIImageView *imageview2 = [[UIImageView alloc] initWithFrame:CGRectMake(WIDTH*2, 0, WIDTH, HEIGHT)]; [imageview2 setImage:[UIImage imageNamed:@"006.png"]]; [scrollView addSubview:imageview2]; UIImageView *imageview3 = [[UIImageView alloc] initWithFrame:CGRectMake(WIDTH*3, 0, WIDTH, HEIGHT)]; [imageview3 setImage:[UIImage imageNamed:@"0.png"]]; imageview3.userInteractionEnabled = YES; //打開imageview3的用戶交互;否則下麵的button無法響應 [scrollView addSubview:imageview3]; UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];//在imageview3上載入一個透明的button [button setTitle:nil forState:UIControlStateNormal]; [button setFrame:CGRectMake(250, 20, 150, 40)]; [button addTarget:self action:@selector(firstpressed) forControlEvents:UIControlEventTouchUpInside]; [button setTitle:@"進入主界面" forState:0]; [button setTitleColor:[UIColor colorWithRed:0.305 green:1.000 blue:0.901 alpha:1.000] forState:0]; [imageview3 addSubview:button]; [self.view addSubview:scrollView]; } - (void)firstpressed { FirstViewController *firstvc=[FirstViewController new]; [self presentViewController: firstvc animated:YES completion:^{ NSLog(@"頁面切換完畢.模態視圖"); }]; } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end
好了, 這個就是我簡單的介紹了。或許不成熟, 但我為之努力。