IOS学习之——欢迎界面
来源:互联网 发布:英语短语软件 知乎 编辑:程序博客网 时间:2024/06/05 05:45
//// MyViewController.m//#import "MyViewController.h"@interface MyViewController () <UIScrollViewDelegate>@property(nonatomic,strong)UIScrollView *sv;@property(nonatomic,strong)UIPageControl *pc;@end@implementation MyViewController//scrollView的代理方法 已经滑动时调用-(void)scrollViewDidScroll:(UIScrollView *)scrollView {// round 返回的是参数中浮点数 四舍五入后 的值 //当前在 第几页上 int currentPageNum = round(scrollView.contentOffset.x / scrollView.frame.size.width); self.pc.currentPage = currentPageNum;}- (void)viewDidLoad { [super viewDidLoad]; //设置 scrollView相关内容 [self configScrllView]; [self configPageControl];}//设置下面的4个原点-(void)configPageControl { self.pc = [[UIPageControl alloc]init]; self.pc.frame = CGRectMake(0, self.view.frame.size.height - 60, self.view.frame.size.width, 40); //有几个点 self.pc.numberOfPages = 4; //当前 选中的时第几个点 默认不设置是0 self.pc.currentPage = 0; //每个点的颜色是什么 self.pc.pageIndicatorTintColor = [UIColor redColor]; //当前 选中的 点 颜色是什么 self.pc.currentPageIndicatorTintColor = [UIColor greenColor]; //关闭用户交互 self.pc.userInteractionEnabled = NO; [self.view addSubview:self.pc];}-(void)configScrllView { //设置 scrollView 的 可见区域和屏幕一样大 self.sv = [[UIScrollView alloc]initWithFrame:self.view.frame]; self.sv.delegate = self; //设置内容区域 self.sv.contentSize = CGSizeMake(4 * self.view.frame.size.width, self.view.frame.size.height); //向scrollView中添加内容 for (int i = 0; i < 4; i++) { NSString *imageName = [NSString stringWithFormat:@"welcome%d", i + 1]; UIImageView *iv = [[UIImageView alloc]initWithImage:[UIImage imageNamed:imageName]]; iv.frame = CGRectMake(i * self.view.frame.size.width, 0, self.view.frame.size.width, self.view.frame.size.height); [self.sv addSubview:iv]; } //设置整页滑动 self.sv.pagingEnabled = YES; //关闭scrollView 的 弹跳 self.sv.bounces = NO; //关闭水平的滑动条 self.sv.showsHorizontalScrollIndicator = NO; [self.view addSubview:self.sv];}- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}/*#pragma mark - Navigation// In a storyboard-based application, you will often want to do a little preparation before navigation- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller.}*/@end
0 0
- IOS学习之——欢迎界面
- 欢迎界面iOS——初学者福利
- IOS学习之——navigationController的界面跳转方法
- IOS学习之——界面2传值到界面1(代理方法)
- iOS学习之——纯代码跳转到xib界面以及storyboard界面
- #Android学习#欢迎界面——ViewPager使用
- Android——欢迎界面
- ViewPager之欢迎界面
- 安卓学习笔记之制作ViewPager欢迎界面
- Android学习之路-----倒计时欢迎界面(更有条理)
- 仿IOS Launch 欢迎界面
- ios 修改欢迎界面图片
- iOS学习之路(三)--界面篇
- android开发之欢迎界面
- ios IOS学习之基础UI界面总结4
- 欢迎界面与引导界面——ViewPager
- Android笔记—如何制作欢迎界面
- android学习——实现欢迎界面图片动画滑动切换
- Android库Volley的使用介绍
- Unity内存优化(-)托管堆ManagedHeap的优化
- poj 3920(简单dp)
- poj 2031 Building a Space Station
- Notice: Undefined index: submit in D:\.....php on line 2问题
- IOS学习之——欢迎界面
- OSI七层模型
- 一切就这样结束了
- java.单例类懒汉式线程安全问题
- Java中的IO介绍
- 一个图像算法岗的面试总结
- 【Spring实战】—— 15 Spring JDBC模板使用
- mysql set name、set character set区别
- Xcode 6 新建工程运行在 iOS 7 上下有黑边的问题