我想制作一个教程屏幕并放置一个滚动视图和一个页面控制器。我想放置图像,以便用户可以在第一次启动时刷过教程屏幕。但是我可以这样贴标签
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
float defWidth = _scrollView.frame.size.width;
float defHeight = _scrollView.frame.size.height;
_scrollView.pagingEnabled = YES;
_scrollView.contentSize = CGSizeMake(defWidth * _pageControl.numberOfPages, _scrollView.frame.size.height);
_scrollView.showsHorizontalScrollIndicator = NO;
_scrollView.showsVerticalScrollIndicator = NO;
_scrollView.scrollsToTop = NO;
_scrollView.bounces = NO;
_scrollView.delegate = self;
UIColor *bgColor[] = {[UIColor orangeColor],[UIColor brownColor],[UIColor grayColor],[UIColor darkGrayColor],[UIColor blackColor]};
for (int i = 0; i < _pageControl.numberOfPages; i++) {
UILabel *label = [[UILabel alloc] init];
float x = (defWidth * (float)i);
label.frame = CGRectMake(x, 0.0f, defWidth, defHeight);
label.backgroundColor = bgColor[i];
label.textColor = [UIColor whiteColor];
label.font = [UIFont fontWithName:@"AppleGothic" size:20];
NSLog(@"%d,%f", i, x);
label.text = [NSString stringWithFormat:@"hogehoge%d", (i + 1)];
NSLog(@"%@", label.text);
[_scrollView addSubview:label];
}
}
但我不能放图像而不是标签。如何将图像放在滚动视图中,使其成为几张图片的幻灯片放映?