Drop-down Refresh

Source: Internet
Author: User

    //1. Add a drop-down refresh controlUirefreshcontrol *refreshcontrol =[[Uirefreshcontrol alloc] init];        [Self.tableview Addsubview:refreshcontrol]; //2. Listening status[Refreshcontrol addtarget:self Action: @selector (Refreshcontrolstatechange:) forControlEvents:        Uicontroleventvaluechanged]; //3. Let the refresh control automatically enter the refresh State[Refreshcontrol beginrefreshing]; //4. Loading Data[self refreshcontrolstatechange:refreshcontrol];- (void) Refreshcontrolstatechange: (Uirefreshcontrol *) refreshcontrol{[Refreshcontrol endrefreshing];}/** * alert users to the latest number of tweets * * @param count the latest number of Weibo*/- (void) Shownewstatusescount: (int) count{//1. Create a UilabelUILabel *label =[[UILabel alloc] init]; //2. Display text    if(count) {Label.text= [NSString stringWithFormat:@"Total%d new Weibo data", Count]; } Else{Label.text=@"no new Weibo data"; }        //3. Setting the backgroundLabel.backgroundcolor = [Uicolor colorwithpatternimage:[uiimage imagewithname:@"Timeline_new_status_background"]]; Label.textalignment=Nstextalignmentcenter; Label.textcolor=[Uicolor Whitecolor]; //4. Set the frameLabel.width =Self.view.width; Label.height= *; Label.x=0; Label.y= --Label.height; //5. Add a view to the navigation controller//[Self.navigationController.view Addsubview:label];[Self.navigationController.view Insertsubview:label BelowSubview:self.navigationController.navigationBar]; //6. AnimationsCGFloat Duration =0.75;//label.alpha = 0.0;[UIView animatewithduration:duration animations:^{        //Move down the height of a labelLabel.transform = Cgaffinetransformmaketranslation (0, label.height);//Label.alpha = 1.0;} completion:^ (BOOL finished) {//Move Down, complete .//after delaying delay seconds, the animation is performed againCGFloat delay =1.0; [UIView animatewithduration:duration delay:delay options:uiviewanimationoptioncurveeaseinout animations:^{                        //revert to the original locationLabel.transform =cgaffinetransformidentity;//label.alpha = 0.0;} Completion:^(BOOL finished) {//Delete a control[Label Removefromsuperview];    }]; }];}/** uiviewanimationoptioncurveeaseinout = 0 << 16,//start: From slow to fast, end: From Fast to slow Uiviewanimationoptioncurveeasein = 1 << 16,//from slow to block uiviewanimationoptioncurveeaseout = 2 << 16,//from fast to slow Uiviewanima Tionoptioncurvelinear = 3 << 16,//linear, constant speed*/

Drop-down Refresh

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.