UIScrollView common attributes and uiscrollview attributes

Source: Internet
Author: User

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

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.