iOS之引導頁的添加

iOS之引導頁的添加

開發APP時 每個APP都有新手引導界面 新手引導頁其實就是在ScrollView添加圖片 並使其能滾動 。

先創建ScrollView對象 新手引導界面就這幾行代碼  

<span style="font-size:14px;">  
   </span><span style="font-size:18px;"> CGRect ScreenRect = [[UIScreen mainScreen] bounds];
    UIScrollView *scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, ScreenRect.size.width, ScreenRect.size.height)];
    [self.view addSubview:scrollView];
    
    for (int i = 0; i<6; i++) {
        NSString *string = [NSString stringWithFormat:@"引導頁%i.jpg",i+1];
        UIImage *forImage = [UIImage imageNamed:string];
        UIImageView *ForImageView = [[UIImageView alloc]initWithImage:forImage];
        ForImageView.frame = CGRectMake(Main_Screen_Width*i, 0, Main_Screen_Width, Main_Screen_Height);
        [scrollView addSubview:ForImageView];
    }
    //設置滾動視圖的內容的大小
    scrollView.contentSize = CGSizeMake(Main_Screen_Width*6, 0);
    //設置分頁
    scrollView.pagingEnabled = YES;

    //再最後一頁上 設置一個button
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(100 +Main_Screen_Width*5, 370, 120, 50);
    [button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
    //button.backgroundColor = [UIColor cyanColor];
    
    [scrollView addSubview:button];
</span>




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章