0
我必须调用给定代码中的图像而不是颜色,我有四个图像可以在这里调用任何一个告诉我如何调用给定代码中的图像...滚动页面控制图像
.h文件中
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController<UIScrollViewDelegate>
@end
.m文件
#import "ViewController.h"
@interface ViewController()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
NSInteger numberOfViews = 3;
for (int i = 0; i < numberOfViews; i++)
{
CGFloat xOrigin = i * self.view.frame.size.width;
UIView *awesomeView = [[UIView alloc] initWithFrame:CGRectMake(xOrigin, 0, self.view.frame.size.width, self.view.frame.size.height)];
awesomeView.backgroundColor = [UIColor colorWithRed:0.5/i green:0.5 blue:0.5 alpha:1];
[scroll addSubview:awesomeView];
[awesomeView release];
}
scroll.contentSize = CGSizeMake(self.view.frame.size.width * numberOfViews, self.view.frame.size.height);
// scroll.pagingEnabled = YES;
scroll.pagingEnabled = YES;
// scroll.contentSize = CGSizeMake(scrollView.frame.size.width * kNumberOfPages, scrollView.frame.size.height);
scroll.showsHorizontalScrollIndicator = NO;
scroll.showsVerticalScrollIndicator = NO;
scroll.scrollsToTop = NO;
// self.pageControl.currentPage = 1;
[self.view addSubview:scroll];
[scroll release];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
现在我需要与使用的编码,而不是厦门国际银行图片的页面控制。
你是什么调用图像意味着页面控制?在哪里调用图像? –
我想添加图像视图的'numberOfViews = 3'.three图像在滚动视图,而不是bg颜色。 – nikesh
你可以添加imageView作为每个视图的子视图与框架CGRectMake(0,0,yourWidth,yourHeight); –