启动图实现:UIScrollView+UIPageControl简单实现
#import "MJViewController.h"
#import "RootViewController.h"
@interface MJViewController () <UIScrollViewDelegate>
@property (strong, nonatomic) UIScrollView *scrollView;
@property (strong, nonatomic) UIPageControl *pageControl;
@property (strong, nonatomic) UIButton *nextBt;
@end
@implementation MJViewController
- (void)viewDidLoad
{
[super viewDidLoad];
//初始化视图
NSArray *array = [NSArray arrayWithObjects:[UIColor redColor],[UIColor blueColor],[UIColor yellowColor],[UIColor purpleColor],[UIColor whiteColor], nil];
self.scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(10, 80, self.view.frame.size.width-20, self.view.frame.size.height-100)];
self.scrollView.backgroundColor = [UIColor groupTableViewBackgroundColor];
self.automaticallyAdjustsScrollViewInsets = NO;//恢复scrollview偏移
self.scrollView.delegate = self;
self.scrollView.pagingEnabled = YES; //分页属性
self.scrollView.showsHorizontalScrollIndicator= NO;
self.scrollView.showsVerticalScrollIndicator = NO;
self.scrollView.contentSize = CGSizeMake((self.view.frame.size.width-20)*[array count], self.scrollView.frame.size.height); //内容范围
[self.view addSubview:self.scrollView];
self.pageControl = [[UIPageControl alloc]initWithFrame:CGRectMake(10,self.view.frame.size.height-50, self.view.frame.size.width-20, 20)];
// self.pageControl.backgroundColor = [UIColor grayColor];
self.pageControl.numberOfPages = array.count;
self.pageControl.currentPage = 0;
[self.view addSubview:self.pageControl];
for (int i = 0; i<array.count; i++) {
UIImageView *imageview = [[UIImageView alloc]initWithFrame:CGRectMake(i*self.scrollView.frame.size.width+5, 5, self.scrollView.frame.size.width-10, self.scrollView.frame.size.height-10)];
imageview.backgroundColor = array[i];
[self.scrollView addSubview:imageview];
if (i==array.count-1) {
imageview.userInteractionEnabled = YES;
self.nextBt = [[UIButton alloc]initWithFrame:CGRectMake(0,0,200, 44)];
_nextBt.alpha = 0.5;
_nextBt.backgroundColor = [UIColor darkGrayColor];
[_nextBt setTitle:@"开启致富之旅" forState:UIControlStateNormal];
[_nextBt setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];
[_nextBt addTarget:self action:@selector(gotoAction) forControlEvents:UIControlEventTouchUpInside];
[imageview addSubview:self.nextBt];
}
}
}
-(void)gotoAction{
RootViewController *rootVC = [[RootViewController alloc]init];
[self presentModalViewController:rootVC animated:YES];
}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
if ([scrollView isMemberOfClass:[UITableView class]]) {
}else{
//在scrollViewDidScroll内实现监听contentOffset内容偏移量;根据contentOffset计算当前属于哪一页;
int index = fabs(scrollView.contentOffset.x)/scrollView.frame.size.width;//当前是第几个视图
self.pageControl.currentPage = index;
}
}
然后在代理里面记得实现:
#pragma mark - 引导页
- (void)setIntroductionViewController
{
//读取沙盒数据
NSUserDefaults * settings1 = [NSUserDefaults standardUserDefaults];
NSString *key1 = [NSString stringWithFormat:@"is_first"];
NSString *value = [settings1 objectForKey:key1];
if (!value) {//如果没有数据
//***
//引导页
introductionVC = [[DMIntroductionViewController alloc]init];
[UIApplication sharedApplication].delegate.window.rootViewController = introductionVC;
}
}
@end
启动图实现:UIScrollView+UIPageControl简单实现的更多相关文章
- swift开发之 -- 自动轮播图(UIScrollView+UIPageControl+Timer)
比较简单,原理就不说了,这里只做记录: 代码如下: 1,准备 var pageControl:UIPageControl? var myscrollView:UIScrollView? var myT ...
- iOS加载启动图的时候隐藏statusbar + 指定启动图显示多少秒
只需需要在info.plist中加入Status bar is initially hidden 设置为YES 补充一下,现在手机越来越快,在6+下面启动图一闪而过,而美工童鞋辛辛苦苦做的图就看不到鸟 ...
- iOS LaunchScreen和LaunchImage的转换启动图
今天开始设置一个新项目的启动图,需要我自己设置,我在UI那拿到以前格式的启动图不知道为何需要那么多图,我记得用LaunchScreen只需一张即可,利用自动布局,今天看到这么多图,发现他用的是Laun ...
- iOS开发简记(1):指定APP的图标与启动图
各位兄弟姐妹们,早上好,本人花了将近一个月的时间打造了一个完整的IOS版的App, 期间包括开发,测试,上线审核,现在花点时间把实现的过程分享给大家,“知音”app功能简单,适合对象为初学者,后面我会 ...
- Mac生成APP图标和启动图的脚本
概述 之前用的一个批量导出APP图标和启动图的软件,今天发现收费了,于是自己造了个简单的轮子. 实现 Mac上的sips命令,可以很方便的帮助用户修改图片尺寸 Xcode里面的APP启动图资源包含两部 ...
- Qt实现炫酷启动图-动态进度条
目录 一.简述 二.动效进度条 1.光效进度条 2.延迟到达进度条 3.接口说明 三.启动图 1.实现思路 2.背景图切换 四.测试 1.构造启动图 2.背景图 3.其他信息 4.事件循环 五.源码 ...
- 用launchscreen.storyboard适配启动图方法(二)
背景 之前有写一篇实现方式比较简单的随笔用launchscreen.storyboard适配启动图方法,顺便在评论区提了一下用autolayout适配启动图的思路,现把思路和流程记录下来. 思路 整体 ...
- Safari配置WebApp----添加启动图和桌面图标让你的WebApp在ios设备上体验如原生一样
现在很多开发者的Web应用程序的设计样式和交互类似本机应用程序,例如,它的缩放比例适合iOS上的整个屏幕.当用户将其添加到主屏幕时,您可以通过使其看起来像本机应用程序一样,在iOS上为您的Web应用程 ...
- flutter添加启动图及设置启动时间
首先贴个官方的设置方法,看这里:https://flutterchina.club/assets-and-images/#%E6%9B%B4%E6%96%B0%E5%90%AF%E5%8A%A8%E9 ...
随机推荐
- [QualityCenter]设置工作流脚本-设置不同字段值关联不同列表
需求:当选择A字段某个值时,设置B字段的列表值根据A字段的值来判断读取不同的列表值,如当运行省份的值已更改, 运行地区的选择列表将更改. 在脚本编辑器新建一个函数UserFuntion_Bug_Pro ...
- SAM4E单片机之旅——22、GMAC和PHY的介绍与初始化
网络通信的作用不用多说,而这次进行的工作即是对以太网通信过程中,需要用到的硬件部分进行初始化,也介绍了发送和接收数据的方法. 由于较为复杂,所以使用了ASF框架.但是也会对用到的库函数的实现做一个介绍 ...
- Oracle查看所有用户
1.查看所有用户:select * from dba_users; select * from all_users; select * from user_users; 2.查看用户或角色系统 ...
- .net WEB程序访问locahost和IP使用
1.服务都在本机调用用 localost 2.部署站点访问时用ip
- WCF MSMQ消息队列与离线操作
消息队列类型 公共队列:整个网络中的节点都可以访问到 专用队列:本地计算机,知道路径者可以访问 管理队列:包含确认在给定“消息队列”网络中的发送的消息回执的消息 相应队列:返回给发送程序的相应信息
- [转帖]迅为4412开发板最小linux系统的存储空间修改
本文转自迅为论坛:http://www.topeetboard.com 最小linux系统的存储空间修改以修改成 1G 存储空间为例来修改,如果需要改成其他大小的存储空间,参照此方法修改即可. 首先连 ...
- 矩阵乘法 codevs 1287 矩阵乘法
1287 矩阵乘法 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题目描述 Description 小明最近在为线性代数而头疼,线性代数确实很抽象 ...
- fontAwesome代替网页icon小图标
引言 奥森图标(Font Awesome)提供丰富的矢量字体图标—通过CSS可以任意控制所有图标的大小 ,颜色,阴影. 网页小图标到处可见,如果一个网页都是干巴巴的文字和图片,而没有小图标,会显得非常 ...
- Codeforces Round #258 D Count Good Substrings --计数
题意:由a和b构成的字符串,如果压缩后变成回文串就是Good字符串.问一个字符串有几个长度为偶数和奇数的Good字串. 分析:可知,因为只有a,b两个字母,所以压缩后肯定为..ababab..这种形式 ...
- Redis漏洞?阿里云被攻击!
今天运维那边过来说阿里云服务器进程被占用很多,后来查了一下进程发现了这个玩意: 小编我看不懂,经运维先森仔细研究,发现这是被注入进来的一个进程,服务器被当成了肉鸡,专门用来跑比特币的,这样对方就不需要 ...