AspectFill
与ScrollView
的效果不太好。
这是我的代码
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
CGFloat pageWidth = self.scrollView.bounds.size.width;
int page = floor((self.scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
self.pageCount= page;
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.scrollView.frame.size.width * self.pageCount, 0, self.scrollView.frame.size.width, self.scrollView.frame.size.height)];
[imageView setImageWithURL:[self.urlArray objectAtIndex:self.pageCount] placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
[imageView setContentMode:UIViewContentModeRedraw];
[self.scrollView addSubview:imageView];
}
答案 0 :(得分:2)
添加:
[scrollView setContentMode:UIViewContentModeScaleAspectFit];
[imageView sizeToFit];
应该工作: - )
答案 1 :(得分:0)
我相信您的滚动视图已启用autoresizesSubviews
,请将其停用并显示您的图片(图片的默认查看模式应该没问题)
答案 2 :(得分:0)
设置scrollview
contentmode
aspectfill
。