【iPhoneX适配】引导页面

This commit is contained in:
xuemh 2018-03-15 22:02:53 +08:00
parent 0dd40d6d5c
commit 4286f754f2
1 changed files with 7 additions and 10 deletions

View File

@ -94,21 +94,18 @@ static MyIntroductionViewController * introduction = nil;
}
-(void)setUpScrollView{
self.scrollView.contentSize = CGSizeMake(self.scrollView.bounds.size.width*self.imageNames.count, self.scrollView.bounds.size.height);
CGFloat width = CGRectGetWidth([UIScreen mainScreen].bounds);
CGFloat height = CGRectGetHeight([UIScreen mainScreen].bounds);
self.scrollView.contentSize = CGSizeMake(width * self.imageNames.count, height);
self.scrollView.bounces=NO;
//views
for (int i=0; i<self.imageNames.count; i++) {
UIImageView * imgV = [[UIImageView alloc]initWithImage:[UIImage imageNamed:self.imageNames[i]]];
imgV.userInteractionEnabled=true;
CGRect frame = imgV.frame;
CGFloat oldH = imgV.bounds.size.height;
CGFloat oldW = imgV.bounds.size.width;
if (frame.size.width>self.scrollView.frame.size.width) {
frame.size.width = self.scrollView.bounds.size.width;
frame.size.height = frame.size.width * oldH / oldW;
imgV.frame = frame;
}
imgV.center = CGPointMake((i+0.5)*self.scrollView.bounds.size.width, self.scrollView.bounds.size.height/2);
imgV.contentMode = UIViewContentModeScaleAspectFill;
imgV.layer.masksToBounds = YES;
CGFloat x = i * width;
imgV.frame = CGRectMake(x, 0, width, height);
[self.scrollView addSubview:imgV];
[self.imageViews addObject:imgV];
}