引导页
2015-09-09 19:56
253 查看
@property (nonatomic,
retain) UIPageControl *page;
// 要先判断是否是第一次启动(一般都是看当前版本是否是第一次启动)
if (![[NSUserDefaults
standardUserDefaults] boolForKey:@"everLaunched"]) {
[[NSUserDefaults
standardUserDefaults] setBool:YES
forKey:@"everLaunched"];
[[NSUserDefaults
standardUserDefaults] setBool:YES
forKey:@"firstLaunch"];
/* scrollView处理 */
UIScrollView *myScroll = [[UIScrollView
alloc] initWithFrame:CGRectMake(0,
0, 375 *
WIDTH, 667 *
HEIGH)];
myScroll.contentSize =
CGSizeMake(375 *
WIDTH * 3,
667 * HEIGH);
for (int i =
0; i < 3; i++) {
UIImageView *myImage = [[UIImageView
alloc] initWithFrame:CGRectMake(375 *
WIDTH * i, 0,
375 * WIDTH,
667 * HEIGH)];
myImage.image = [UIImage
imageNamed:[NSString
stringWithFormat:@"引导图%d", i +
1]];
[myScroll
addSubview:myImage];
}
myScroll.pagingEnabled =
YES;
myScroll.showsHorizontalScrollIndicator =
NO;
myScroll.bounces =
NO;
[self.window
addSubview:myScroll];
/*
最后一个页面设置一个button */
UIButton *button = [UIButton
buttonWithType:(UIButtonTypeCustom)];
[myScroll
addSubview:button];
// button.backgroundColor = [UIColor orangeColor];
button.frame =
CGRectMake(self.window.frame.size.width *
2 + self.window.frame.size.width /
2 - 100 *
WIDTH, self.window.frame.size.height -
215 * HEIGH,
200, 100);
button.tintColor = [UIColor
blackColor];
button.titleLabel.font = [UIFont
systemFontOfSize:20];
[button addTarget:self
action:@selector(click)
forControlEvents:(UIControlEventTouchUpInside)];
[button setTitle:@""
forState:UIControlStateNormal];
/*
签订协议 */
myScroll.delegate =
self;
/*
页面处理 */
self.page = [[UIPageControl
alloc] initWithFrame:CGRectMake(0,
620 * HEIGH,
375*WIDTH,
30)];
self.page.numberOfPages =
3;
self.page.currentPage =
0;
self.page.backgroundColor = [UIColor
clearColor];
self.page.currentPageIndicatorTintColor = [UIColor
cyanColor];
self.page.pageIndicatorTintColor = [UIColor
whiteColor];
[self.window
addSubview:self.page];
}
else {
[[NSUserDefaults
standardUserDefaults] setBool:NO
forKey:@"firstLaunch"];
self.window.rootViewController =
self.sideMenuVC;
}
/* button的点击方法,处理跳转 */
- (void)click
{
self.window.rootViewController =
self.sideMenuVC;
}
/* 页面移动处理 */
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
self.page.currentPage = scrollView.contentOffset.x
/ scrollView.window.frame.size.width;
}
retain) UIPageControl *page;
// 要先判断是否是第一次启动(一般都是看当前版本是否是第一次启动)
if (![[NSUserDefaults
standardUserDefaults] boolForKey:@"everLaunched"]) {
[[NSUserDefaults
standardUserDefaults] setBool:YES
forKey:@"everLaunched"];
[[NSUserDefaults
standardUserDefaults] setBool:YES
forKey:@"firstLaunch"];
/* scrollView处理 */
UIScrollView *myScroll = [[UIScrollView
alloc] initWithFrame:CGRectMake(0,
0, 375 *
WIDTH, 667 *
HEIGH)];
myScroll.contentSize =
CGSizeMake(375 *
WIDTH * 3,
667 * HEIGH);
for (int i =
0; i < 3; i++) {
UIImageView *myImage = [[UIImageView
alloc] initWithFrame:CGRectMake(375 *
WIDTH * i, 0,
375 * WIDTH,
667 * HEIGH)];
myImage.image = [UIImage
imageNamed:[NSString
stringWithFormat:@"引导图%d", i +
1]];
[myScroll
addSubview:myImage];
}
myScroll.pagingEnabled =
YES;
myScroll.showsHorizontalScrollIndicator =
NO;
myScroll.bounces =
NO;
[self.window
addSubview:myScroll];
/*
最后一个页面设置一个button */
UIButton *button = [UIButton
buttonWithType:(UIButtonTypeCustom)];
[myScroll
addSubview:button];
// button.backgroundColor = [UIColor orangeColor];
button.frame =
CGRectMake(self.window.frame.size.width *
2 + self.window.frame.size.width /
2 - 100 *
WIDTH, self.window.frame.size.height -
215 * HEIGH,
200, 100);
button.tintColor = [UIColor
blackColor];
button.titleLabel.font = [UIFont
systemFontOfSize:20];
[button addTarget:self
action:@selector(click)
forControlEvents:(UIControlEventTouchUpInside)];
[button setTitle:@""
forState:UIControlStateNormal];
/*
签订协议 */
myScroll.delegate =
self;
/*
页面处理 */
self.page = [[UIPageControl
alloc] initWithFrame:CGRectMake(0,
620 * HEIGH,
375*WIDTH,
30)];
self.page.numberOfPages =
3;
self.page.currentPage =
0;
self.page.backgroundColor = [UIColor
clearColor];
self.page.currentPageIndicatorTintColor = [UIColor
cyanColor];
self.page.pageIndicatorTintColor = [UIColor
whiteColor];
[self.window
addSubview:self.page];
}
else {
[[NSUserDefaults
standardUserDefaults] setBool:NO
forKey:@"firstLaunch"];
self.window.rootViewController =
self.sideMenuVC;
}
/* button的点击方法,处理跳转 */
- (void)click
{
self.window.rootViewController =
self.sideMenuVC;
}
/* 页面移动处理 */
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
self.page.currentPage = scrollView.contentOffset.x
/ scrollView.window.frame.size.width;
}
相关文章推荐
- 时间问题
- huffman coding
- NYOJ 7 街区最短路径问题
- 研究生入学初期感悟
- BZOJ 1028: [JSOI2007]麻将 暴力
- 0909关于编译原理
- 如何去设计一个自适应的网页设计或HTMl5
- php-fpm的配置
- Windows 10 关键错误,“开始”菜单和 Cortana 无法工作。你下次登录时,我们将尝试解决此问题的解决方法
- POJ 2195 Going Home
- C++用法及学习心得
- Web移动端使用localStorage缓存Js和css文件
- 用busybox搭建最简单的Linux文件系统
- MySQL两种方法创建自增列
- AsyncTask的个人使用总结
- Android0908<十三>(部分Service、 ContentProvider、 BroadcastReceiver)
- ios-音乐播放器-(3)后台播放
- 后缀数组 DC3构造法 —— 详解
- 【LeetCode】165. Compare Version Numbers
- linux常用命令 git