本文介绍了app欢迎页的简单实现。只有第一次运行程序时才说会出现,其余时间不会出现。下面是效果图。

代码如下:(如有不明白的可以评论我,我会详细讲解)

//
// ViewController.m
// CX IOS欢迎页
//
// Created by ma c on 16/3/18.
// Copyright © 2016年 xubaoaichiyu. All rights reserved.
// #import "ViewController.h" @interface ViewController ()<UIScrollViewDelegate> @property (nonatomic, strong) UIScrollView * scrollView;
@property (nonatomic, strong) UIPageControl * pageControl; @end @implementation ViewController
#pragma mark - life
- (void)viewDidLoad {
[super viewDidLoad];
//判断是否是第一次运行程序
NSUserDefaults * userDefaults = [NSUserDefaults standardUserDefaults];
// [userDefaults removeObjectForKey:@"FirstLoad"];
if ([userDefaults objectForKey:@"FirstLoad"] == nil) {
[userDefaults setBool:NO forKey:@"FirstLoad"];
[self loadScrollView];
} }
#pragma mark - deleDate -(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{ CGPoint point = self.scrollView.contentOffset; NSInteger current = point.x / self.view.frame.size.width; self.pageControl.currentPage = current; } #pragma mark - function
-(void)loadScrollView{ CGRect rect = [UIScreen mainScreen].bounds; self.scrollView = [[UIScrollView alloc]initWithFrame:rect];
//分页
self.scrollView.pagingEnabled = YES; self.scrollView.delegate = self; self.scrollView.showsHorizontalScrollIndicator = NO; self.scrollView.showsVerticalScrollIndicator = NO;
//scrollView滚动区域大小
self.scrollView.contentSize = CGSizeMake(rect.size.width * , rect.size.height); for (NSInteger i = ; i < ; i ++) { UIImageView * imageView = [[UIImageView alloc]init]; imageView.frame = CGRectMake(i * rect.size.width, , rect.size.width, rect.size.height);
//为了区别imageView而又简单操作,建立随机颜色。
imageView.backgroundColor = [UIColor colorWithRed:arc4random() % / .f green:arc4random() % / .f blue:arc4random() % / .f alpha:];
[self.scrollView addSubview:imageView]; //添加开启软件
UIButton * removeBUtton = [UIButton buttonWithType:UIButtonTypeCustom]; removeBUtton.frame = CGRectMake( + * rect.size.width, rect.size.height * 0.7, rect.size.width - , ); [removeBUtton setTitle:@"开启旅行" forState:UIControlStateNormal]; [removeBUtton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; removeBUtton.backgroundColor = [UIColor orangeColor]; [removeBUtton addTarget:self action:@selector(start) forControlEvents:UIControlEventTouchUpInside]; [self.scrollView addSubview:removeBUtton];
} [self.view addSubview:self.scrollView]; [self loadPageControl]; } -(void)start{ [self.pageControl removeFromSuperview]; [self.scrollView removeFromSuperview]; }
-(void)loadPageControl{ CGRect rect = [UIScreen mainScreen].bounds; self.pageControl = [[UIPageControl alloc]init]; self.pageControl.numberOfPages = ; CGSize pageControlSize = [self.pageControl sizeForNumberOfPages:]; self.pageControl.frame = CGRectMake((rect.size.width - pageControlSize.width) / , rect.size.height * 0.8, pageControlSize.width, pageControlSize.height); self.pageControl.currentPage = ; self.pageControl.currentPageIndicatorTintColor = [UIColor greenColor]; self.pageControl.pageIndicatorTintColor = [UIColor grayColor]; [self.view addSubview:self.pageControl]; [self.view bringSubviewToFront: self.pageControl]; }
@end

IOS 欢迎页(UIScrollView,UIPageControl)的更多相关文章

  1. IOS初级:UIScrollView & UIPageControl

    UIScrollView其实构建的就像一列很长的火车,每滑动一个屏幕,展示一节车厢. //主屏幕高度 #define kScreenHeight [UIScreen mainScreen].bound ...

  2. 【iOS系列】-UIScrollView的介绍及结合UIPageControl实现图片播放的实例

    [iOS系列]-UIScrollView的介绍及结合UIPageControl实现图片播放的实例 第一:UIScrollView的常用属性 //表示UIScrollView内容的尺寸,滚动范围 @pr ...

  3. UIScrollView,UIPageControl

    #import <UIKit/UIKit.h> @interface ViewController : UIViewController<UIScrollViewDelegate&g ...

  4. iOS纯代码制作欢迎界面——UIScrollView, UIPageControl, UIImageView,UIButton, NSTimer

    欢迎界面,还是比较简单的,一个UIScrollView控件,一个UIPageControl,几个UIImageView即可摆平.在这里光玩这些,就显得诚意不足了.特意拓展一下,再加几个UIButton ...

  5. IOS 怎么用UIScrollView来滚动和缩放他的内容第一篇

    本篇文章来自于互联网资料翻译 UIScrollView是在IOS最有用的控件之一.他是一个来展现超过一个屏幕的内容的很好的方式.下面有很多的技巧来使用他. 这篇文章就是关于UIScrollView的, ...

  6. iOS新手引导页的实现,源码。

    /*.在Main.storyboard中找到,ScrollView和PageControl并添加到ViewController中. .在ScrollView中添加ImageView,新手引导页有几个图 ...

  7. UIScrollView,UIPageControl,UIImageView 实现图片轮播的效果

    上一篇博客介绍了如何将XCode创立的项目提交到Git版本控制,这次就直接做一个图片轮播的展示demo,刚好可以把UIScrollView.UIPageControl.UIImageView这三个控件 ...

  8. 启动图实现:UIScrollView+UIPageControl简单实现

    #import "MJViewController.h"#import "RootViewController.h" @interface MJViewCont ...

  9. iOS学习之UIScrollView

    一.UIScrollView的创建和常用属性      1.UIScrollView概述 UIScrollView是UIView的子类. UIScrollView作为所有滚动视图的基类. UIScro ...

随机推荐

  1. DalekJS – 基于 JavaScript 实现跨浏览器的自动化测试

    在 Web 项目中,浏览器兼容以及跨浏览器测试是最重要的也是最费劲的工作.DalekJS 是一个基于 JavaScript(或 Node.js) 的免费和开源的自动化测试接口.它能够同时运行测试一组流 ...

  2. mysqlbinlog -v --base64-output 与不加的区别

    加-v与加-vv的区别: 加--base64-output=DECODE-ROWS与不加的区别:

  3. Linq查询操作之Where筛选

    筛选操作where能够处理逻辑运算符组成的逻辑表达式.比如逻辑“与”,逻辑“或”,并从数据源中筛选数据,它和where子句的功能非常相似.Enumerable类的Where()原型如下: public ...

  4. PHP验证邮箱地址代码

    PHP验证邮箱代码: function isEmail($email) { return strlen($email) > 6 && preg_match("/^[\w ...

  5. C#开发规范总结(个人建议)

    .NET开发编程规范 章程序的版式 版式虽然不会影响程序的功能,但会影响可读性.程序的版式追求清晰.美观,是程序风格的重要构成因素. 可以把程序的版式比喻为"书法".好的" ...

  6. 你可以做一个更好的Coder为了自己的将来

    小小的星辰 工作已经一年多了,时间真的好快啊!发现自己还是终于走出了当初的阴影!我可以快乐的做我自己了.这两年发现自己改变了很多!很庆幸,我可以不想你了!伤感的心情总会过去的.还记得曾经说过一句:“离 ...

  7. MySQL SQL模式匹配

    MySQL提供标准的SQL模式匹配,SQL模式匹配允许你使用“_”匹配任何单个字符,而“%”匹配任意数目字符(包括零字符).. 关于SQL模式匹配:http://dev.mysql.com/doc/r ...

  8. Python基础(二),Day2

    常用的数据类型 int 整型 float 浮点 bool 布尔 string 字符串 列表的语法和用法 # 创建一个列表 list = [] #一个空列表 list = ['2323123','asd ...

  9. Python 学习笔记1

    1.Python2.x与3​​.x版本区别 2.常量与变量 3.if  elif  else 4.注释 5.用户交互 6.字符串拼接 7.文件扩展名 8.缩进 9.运算符 10.while循环 Pyt ...

  10. long(Long)与int(Integer)之间的转换

    最近由于在做一个众筹的项目,其中有一个查找项目支持数的接口,查找的方法定义的是一个long型的,我更新项目中的支持数的时候是int型的,所以需要在long型与int型之间转化,下面把转转化的详细方法记 ...