02-uiscrollview Bottom-level implementation

Source: Internet
Author: User

 uiscrollview Bottom -level implementation: Modify bounds, equal to uiscrollview contentoffset offset  #import "ViewController.h"  @interface Viewcontroller () <uiscrollviewdelegate>  @property(Nonatomic,Weak) UIView *scrollview;

@end

@implementation Viewcontroller

-(void) viewdidload { [Super Viewdidload];   UIView*scorllview = [[UIViewAlloc]initWithFrame:Self.View.Bounds];
[Self.ViewAddsubview: Scorllview];
_scrollview= Scorllview;

//Add toPanGesture
Uipangesturerecognizer*pan = [[UipangesturerecognizerAlloc]Initwithtarget:SelfAction:@selector(pan:)];
[ScorllviewAddgesturerecognizer:p an];

Uiswitch*switchview = [[UiswitchAlloc]Init];
[ScorllviewAddsubview: SwitchView];

1.UIViewAdd aPanGesture
2.Move your fingers upwards.,Content go up,Want to see the following content, bounds.y++

}

- (void) Pan: (Uipangesturerecognizer*) Pan
{
//Get finger Offset
CgpointTRANSP = [panTranslationinview:p an.View];
CGFloatOffsetY =-TRANSP.Y;

//ModifyBounds
CGRectBounds =_scrollview.Bounds;
Bounds.Origin.Y+ = OffsetY;
_scrollview.Bounds= bounds;

//Reset
[PanSettranslation:cgpointzero inview:p an. View];


//NSLog (@ "%f", OffsetY); }
//As soon as a scroll is called
- (void) Scrollviewdidscroll: (Uiscrollview*) ScrollView
{
NSLog(@"%@ %@",nsstringfromcgpoint(scrollView. Contentoffset),nsstringfromcgrect(scrollView. Bounds)); }// @end

02-uiscrollview Bottom-level implementation

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.