How can I use UIScrollView?

2019-04-07 17:06发布

How can I use UIScrollView? please give me a simple example with one scrolling image?

7条回答
成全新的幸福
3楼-- · 2019-04-07 17:17
迷人小祖宗
4楼-- · 2019-04-07 17:19

You can use below code to add UIScrollView on yourView :-

[self.ScrollView setContentSize:(CGSizeMake(self.view.frame.size.width, self.view.frame.size.height))];

Step:1 Create a UiScrollView,

@interface ViewController : UIViewController
@property (strong, nonatomic) IBOutlet UIScrollView *MyScrollView;
@end

Step2: In your ViewController.m,

[self.MyScrollView setContentSize:(CGSizeMake(self.view.frame.size.width, self.view.frame.size.height))];
查看更多
仙女界的扛把子
5楼-- · 2019-04-07 17:20

Have a look at Apple's example apps:

And of course at Apple's official documentation:

查看更多
Emotional °昔
6楼-- · 2019-04-07 17:26

Here is a link for all good tutorials: Code link

This link explain you basic steps for how to use: Steps link

This is a example of scrollview with one scrolling image using XIB and just few lines of code: scrollview with xib
Thanks

查看更多
虎瘦雄心在
7楼-- · 2019-04-07 17:28

Add UIImageView in to UIScrollView.

then,

Use

imageView.image = [UIImage imageNamed:@"image1.png"];
imageView.frame = CGRectMake(0.0, 0.0, imageView.image.size.width, imageView.image.size.height);
scrollView.contentSize = CGSizeMake(imageView.image.size.width, imageView.image.size.height);
查看更多
登录 后发表回答