gpt4 book ai didi

iphone - 将 UIImageView 添加到 UIScrollView

转载 作者:太空狗 更新时间:2023-10-30 03:48:27 24 4
gpt4 key购买 nike

我目前正在研究将多个 UIImageView 添加到单个 UIScrollView 的方法。 UIScrollView 将是任何一个 UIImageViews 大小的 1.5 倍。我想创建一个滚动效果来浏览 iPad 应用程序中的一些小图像。有谁知道如何实现这一点?

最佳答案

UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(/*FRAME*/)]; // this makes the scroll view - set the frame as the size you want to SHOW on the screen
[scrollView setContentSize:CGSizeMake(/*SIZE OF THE CONTENT*/)]; // if you set it to larger than the frame the overflow will be hidden and the view will scroll

/* you can do this bit as many times as you want... make sure you set each image at a different origin */
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"/*IMAGE*/"]]; // this makes the image view
[imageView setFrame:CGRectMake(/*SET AS 2/3 THE SIZE OF scrollView AND EACH IMAGE NEXT TO THE LAST*/)]; // this makes the image view display where you want it and at the right size
[scrollView addSubview:imageView]; // this adds the image to the scrollview
/* end adding image */

[self.view addSubview:scrollView];

关于iphone - 将 UIImageView 添加到 UIScrollView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3777364/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com