博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
IOS博客项目搭建-12-刷新数据-显示最新的微博数提示
阅读量:2385 次
发布时间:2019-05-10

本文共 2447 字,大约阅读时间需要 8 分钟。

     用户下拉微博view时,会出现一个刷新的图标,当有新数据时,我们希望为用户提示此次刷新了多少条数据,这个提示栏该怎么做呢?考虑一下。。。

   OK,经过分析,可以考虑使用UIButton控件来做这个提示栏。

分析图:

110527_9hk0_2557944.png

实际效果图

112118_LLPC_2557944.png

在刷新控件的状态的改变方法中添加显示微博数据提示的方法:

/** *  监听刷新控件的状态改变(手动进入刷新状态才会调用这个方法) */ -(void)refreshControlStateChange:(UIRefreshControl*)refreshControl{ // 省略获取数据的代码...      // 显示最新微博的数量(给用户一些友善的提示) statusFrameArray.count 更新的数据数  [self showNewStatusCount:statusFrameArray.count];}

显示更新提示数的具体方法:

/** *  显示微博数据 */-(void)showNewStatusCount:(int)count{    // 1.创建一个按钮    UIButton *btn = [[UIButton alloc] init];            // below:添加在导航栏的下面    [self.navigationController.view insertSubview:btn belowSubview:self.navigationController.navigationBar];        // 2.设置按钮背景图片和文字属性    btn.userInteractionEnabled = NO;    [btn setBackgroundImage:[UIImage resizedImageWithName:@"timeline_new_status_background"] forState:UIControlStateNormal];    [btn setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];  // 设置标题文字颜色    btn.titleLabel.font = [UIFont systemFontOfSize:14];  // 设置字体大小        if(count){        NSString *title = [NSString stringWithFormat:@"共有%d条新的微博", count];        [btn setTitle:title forState:UIControlStateNormal];    }else{        [btn setTitle:@"没有新的微博" forState:UIControlStateNormal];    }        // 3.设置按钮的初始frame    CGFloat btnH = 30;    CGFloat btnY = 64 - btnH;    CGFloat btnX = 2;    CGFloat btnW = self.view.frame.size.width - 2 * btnX;        btn.frame = CGRectMake(btnX, btnY, btnW, btnH);        // 4.通过动画移动按钮(按钮向下移动btnH + 1)    [UIView animateWithDuration:1.0 animations:^{        btn.transform = CGAffineTransformMakeTranslation(0, btnH + 1);    } completion:^(BOOL finished) { // 向下移动的动画执行完毕后        // 说明:该方法(animateKeyframesWithDuration)只能在IOS7以上版本才能执行,兼容低版本iOS6,需要用animateWithDuration方法        [UIView animateWithDuration:1.0 delay:0.7 options:(UIViewAnimationOptionCurveLinear) animations:^{            btn.transform = CGAffineTransformIdentity;        } completion:^(BOOL finished) {            // 将btn从内存中移除            [btn removeFromSuperview];        }];        /*        [UIView animateKeyframesWithDuration:1.0 delay:1.0 options:UIViewKeyframeAnimationOptionCalculationModeLinear animations:^{ // 执行向上移动的动画(清空transform)                        btn.transform = CGAffineTransformIdentity;                    } completion:^(BOOL finished) {            // 将btn从内存中移除            [btn removeFromSuperview];                    }];         */    }];}

添加动画后的实际效果图:

17124649_TPpo.gif

转载于:https://my.oschina.net/corwien/blog/661340

你可能感兴趣的文章
PCI DSS Update Could Include Virtualization Security(转载自baoz)
查看>>
List of Windows Auto Start Locations
查看>>
OSSIM 2.1 - Multiple security vulnerabilities
查看>>
PHP文件上传源码分析(RFC1867)
查看>>
关于php5.*后的时区问题 date_default_timezone_set ();
查看>>
SX 4th meetup – Hunting Rootkit From the Dark Corners Of Memory
查看>>
“Cache-control”常见的取值有private、no-cache、max-age、must-revalidate等
查看>>
安全工具集合
查看>>
Metasploit 3.3 Development Updates
查看>>
Windows Services for UNIX Version 3.5
查看>>
Linux 测试工具
查看>>
Modifying SSH to Capture Login Credentials from Attackers
查看>>
FlatPress 0.804-0.812.1 Local File Inclusion to Remote Command Execution
查看>>
WinRAR v3.80 - ZIP Filename Spoofing
查看>>
shred
查看>>
malware自动化分析
查看>>
opendns安全研究成果
查看>>
Real world examples of malware using DNS for exfiltration and C&C channels
查看>>
Investigating A Malicious Attachment Without Reversing
查看>>
Detecting HTTP Load Balancers using Halberd
查看>>