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>