UIScrollView common attributes and uiscrollview attributes
What is UIScrollView • the screen size of the device is extremely limited, so the content displayed directly in front of the user is quite limited • when there is more content than one screen, you can use a scroll gesture to view content outside the screen • a normal UIView does not have the scroll function and cannot display too much content • UIScrollView is a view control that can be rolled, it can be used to display a large amount of content, and you can scroll to view all the content
• Example: "Settings" and other sample programs on the mobile phone • If UIScrollView cannot be rolled, it may be due to the following: userInteractionEnabled = NO. The autolayout function is not canceled (autolayout must be canceled for scrollView scrolling ...... Common UIScrollView attributes • @ property (nonatomic) CGPoint contentOffset; Ø this attribute is used to indicate the scroll position of UIScrollView
• @ Property (nonatomic) CGSize contentSize; Ø this attribute is used to indicate the size of UIScrollView content and the scroll range (how far can it be rolled) • @ property (nonatomic) UIEdgeInsets contentInset; this attribute can be implemented by adding additional code for the rolling area in four weeks of UIScrollView.
Main. storyboard
If you add a button here, it cannot be added to Scoll View.
# Import "ViewController. h"
@ Interface ViewController ()
@ Property (weak, nonatomic) IBOutlet UIScrollView * scrollView;
@ Property (weak, nonatomic) IBOutlet UIImageView * imageView;
-(IBAction) btn;
@ End
@ Implementation ViewController
-(Void) viewDidLoad {
[Super viewDidLoad];
// Scroll range
Self. scrollView. contentSize = self. imageView. frame. size;
// Scroll margin
Self. scrollView. contentInset = UIEdgeInsetsMake (10, 20, 30, 40 );
}
-(Void) didReceiveMemoryWarning {
[Super didReceiveMemoryWarning];
}
-(IBAction) btn {
// Center Coordinate
CGPoint offest = CGPointMake (100,100 );
// CGPoint offest = self. scrollView. contentOffset;
// Offest. x ++ = 100;
// Offest. y + = 100;
[Self. scrollView setContentOffset: offest animated: YES];
}
@ End