The use of IOS-Uiscrollview basic Properties (Contentsize, Contentinset, Contentoffset)

Source: Internet
Author: User

#import "ViewController.h"
@interface Viewcontroller ()
@property (Weak, nonatomic) Iboutlet Uiscrollview *scrollview;
@property (Weak, nonatomic) Iboutlet Uiimageview *minionview;
-(ibaction) scroll;
@end
@implementation Viewcontroller
-(void) viewdidload{
[Super Viewdidload];
Set the size of the ScrollView content (scrolling range)
Self.scrollView.contentSize = Cgsizemake (892, 480);
Self.scrollView.contentSize = self.minionView.image.size;

Scope of the overall content (scrolling range)
self.scrollView.contentSize = self.minionView.frame.size;
< #CGFloat Top#>, < #CGFloat Left#>, < #CGFloat Bottom#>, < #CGFloat right#>
Self.scrollView.contentInset = Uiedgeinsetsmake (ten , +, +);
Self.scrollView.frame.size; Visual Range
}
-(ibaction) Scroll {
[UIView animatewithduration:1.0 animations:^{
Self.scrollView.contentOffset = cgpointmake (100, 0);
//    }];
Cgpoint offset = cgpointmake (-100,-100);
cgpoint offset = self.scrollView.contentOffset;
Offset.x + = 10;
Offset.y + = 10;
[Self.scrollview Setcontentoffset:offset Animated:yes];
}
@end

Simple Himalaya Interface Code
@interface Viewcontroller ()
@property (Weak, nonatomic) Iboutlet Uiscrollview *scrollview;

@property (Weak, nonatomic) Iboutlet UIButton *lastbtn;
@end
@implementation Viewcontroller
-(void) viewdidload{
[Super Viewdidload];
Set Content Size
CGFloat contenth = self.lastbtn.frame.origin.y + self.lastbtn.frame.size.height+ 10;
10 is the spacing at the bottom
cgfloat contenth = Cgrectgetmaxy (self.lastBtn.frame) + ten;
self.scrollView.contentSize = Cgsizemake (0, Contenth);
Add additional scrolling area (add 64 to the top of the area and add 44 to the bottom)
Self.scrollView.contentInset = Uiedgeinsetsmake (64, 0, 44, 0);
Set the start scroll position (scroll down 64)
Self.scrollView.contentOffset = Cgpointmake (0,-64);
}
@end

The use of IOS-Uiscrollview basic Properties (Contentsize, Contentinset, Contentoffset)

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.