//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