1

是否可以在 UIScrollView 和 PageControl 显示的视图之间添加一些黑色空间。这些视图中的每一个都是一个简单的视图控制器,其中包含一个 UiImageView,类似于相册。我想添加空间,所以当用户切换“页面”/照片时,两者之间会有一些差距。

    scrollArea.pagingEnabled = YES;
    scrollArea.contentSize = CGSizeMake(scrollArea.frame.size.width * [photos count], scrollArea.frame.size.height);
    scrollArea.showsHorizontalScrollIndicator = NO;
    scrollArea.showsVerticalScrollIndicator = NO;
    scrollArea.scrollsToTop = NO;
    scrollArea.delegate = self;

我不想让图像变小,但这可以解决问题。有任何想法吗?

4

1 回答 1

1

是的,您可以完全控制 UIScrollView 内所有 UIView 的放置以及与滚动视图相关的页面控件的放置。没有完成自动布局,您可以正确设置所有对象的 frame 属性,以便它们“很好地”适合滚动视图的“页面”(可见区域 = 一个“页面”)

这是一个将内容添加到滚动视图中每个页面中特定 x,y 的多个“页面”的示例:

NSMutableArray *myLabels = [NSMutableArray arrayWithCapacity:numPages];
CGFloat itemX = 10;
CGFloat itemY = 20;
CGFloat itemWidth = 40;
CGFloat itemHeight = 50;

for ( int i = 0; i < numPages; ++i )
{
    UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake( itemX, itemY, itemWidth, itemHeight )];
    [myScrollView addSubview:lbl];
    [myLabels addObject:lbl];
    [lbl release];
    itemX += myScrollView.frame.size.width;
}
于 2011-03-01T07:13:39.117 回答