iOS引導(dǎo)頁面(點(diǎn)擊進(jìn)入主界面的)

import "yindaoViewController.h"

import "ViewController.h"

@interface yindaoViewController ()<UIScrollViewDelegate>
{
UIScrollView *scrollV;
NSArray *imgArr;
}
@end

@implementation yindaoViewController

  • (void)viewDidLoad {
    [super viewDidLoad];
// 滾動視圖圖
scrollV = [[UIScrollView alloc]initWithFrame:self.view.frame];
// 設(shè)置代理
scrollV.delegate =self;
// 將scroll 添加到加入到視圖上
[self.view addSubview:scrollV];
// 圖片數(shù)組
imgArr = @[@"1",@"2",@"3",@"4"];
// 使用for 來循環(huán)設(shè)置圖片
for(int i =0; i <4; i++)
{
    // 設(shè)置圖片框
    UIImageView *imgV = [[UIImageView alloc]initWithFrame:CGRectMake(self.view.frame.size.width *i,0, self.view.frame.size.width, self.view.frame.size.height)];
    // 設(shè)置圖片
    imgV.image = [UIImage imageNamed:imgArr[i]];
    // 允許與用戶交互
    imgV.userInteractionEnabled = YES;
    
    if(i == 3){
        
        // 按鈕
        UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake((self.view.frame.size.width-200)/2, 600, 200, 40)];
        // 標(biāo)題
        [btn setTitle:@"立即體驗(yàn)" forState:UIControlStateNormal];
        // 按鈕顏色
        btn.backgroundColor = [UIColor redColor];
        //按鈕文字顏色
        [btn setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];
        // 添加事件
        [btn addTarget:self action:@selector(GoTo) forControlEvents:UIControlEventTouchUpInside];
        
        [imgV addSubview:btn];
    }
    
    
    [scrollV addSubview:imgV];
    
}
// 設(shè)置滾動范圍
scrollV.contentSize = CGSizeMake(self.view.frame.size.width *4, self.view.frame.size.height);
// 設(shè)置分頁滾動
scrollV.pagingEnabled = YES;
// 隱藏水平滾動條
scrollV.showsHorizontalScrollIndicator =NO;

}
-(void)GoTo{

ViewController *main = [ViewController new];
// 采取從下往上的方式跳轉(zhuǎn)
[self presentViewController:main animated:YES completion:nil];

}

@end

在AppDelegate里初始化剛才的頁面

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容