UI06_UIPageControl
来源:互联网 发布:最好的大六壬排盘软件 编辑:程序博客网 时间:2024/06/05 16:20
#define WIDTH self.view.frame.size.width#define HEIGHT self.view.frame.size.height@interface RootViewController ()<UIScrollViewDelegate>@property(nonatomic,retain)UIScrollView *scorllView;@property(nonatomic,retain)UIPageControl *page;@end@implementation RootViewController- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. self.view.backgroundColor = [UIColor orangeColor]; //七张图的相册 //尺寸是屏幕高的一半,宽是屏幕宽 self.scorllView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT/2+100)]; self.scorllView.backgroundColor = [UIColor yellowColor]; [self.view addSubview:self.scorllView]; [_scorllView release]; self.scorllView.contentSize = CGSizeMake(7*WIDTH, 0); self.scorllView.pagingEnabled = YES; self.scorllView.delegate = self; for (NSInteger i = 1; i< 8; i++) { NSString *imageName = [NSString stringWithFormat:@"h%ld.jpeg",i]; UIImage *image = [UIImage imageNamed:imageName]; UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake((i-1)*WIDTH, 0, WIDTH, HEIGHT/2)]; imageView.image = image; [self.scorllView addSubview:imageView]; [imageView release];} self.page = [[UIPageControl alloc] initWithFrame:CGRectMake(100, HEIGHT/2+100, 150, 50)]; self.page.backgroundColor = [UIColor blueColor]; [self.view addSubview:self.page]; [_page release]; self.page.numberOfPages = 7; self.page.pageIndicatorTintColor = [UIColor redColor]; self.page.currentPageIndicatorTintColor = [UIColor greenColor]; [self.page addTarget:self action:@selector(click:) forControlEvents:UIControlEventValueChanged]; //设置最大的缩放比例 self.scorllView.maximumZoomScale = 2; //最小的缩放比例 self.scorllView.minimumZoomScale = 0.5;}//控制缩放的方法-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{ UIView *view = scrollView.subviews[(NSInteger)scrollView.contentOffset.x/(NSInteger)WIDTH]; //只要进行缩放,系统就会修改scrollView的contentSize的值,所以当缩小之后,没有办法在进行拖拽 NSLog(@"%g",scrollView.contentSize.width); return view;}-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{ self.page.currentPage = scrollView.contentOffset.x/WIDTH;}-(void)click:(UIPageControl *)page{ NSLog(@"%ld",self.page.currentPage); self.scorllView.contentOffset = CGPointMake(WIDTH*page.currentPage, 0);}- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}- (void)dealloc{ [_scorllView release]; [_page release]; [super dealloc];}@end
0 0
- UI06_UIPageControl
- UI06_UIPageControl
- UI06_UIPageControl
- UI06_UIPageControl
- iOS UI06_UIPageControl
- Ubuntu下如何解压缩zip,tar,tar.gz,tar.bz2文件
- MapReduce分析日志---代码流程解读
- Ubuntu搭建Android开发环境
- HDU 1180 诡异的楼梯 BFS
- 关于基类析构函数的问题 http://bbs.csdn.net/topics/390543618
- UI06_UIPageControl
- 使用FreeImage写通用图像加载器
- E-R图设计的步骤
- pAdTy_4 构建有联系人和签署的应用程序
- DOM 对象控制 HTML
- 实战c++中的vector系列--构造、operator=和assign区别
- Valid Parentheses
- Unity3D 把代码混淆过的代码返混淆回来
- LogCat中没有信息显示:device disconnected:1