iOS开发NSTimer闪烁问题
2016-01-05 19:23
501 查看
iOS开发中,有一个验证码倒计时的场景,实现起来不困难,但做完之后会发现一个很奇怪的现象,每秒闪烁一下,让人很烦,如果不希望这个效果,很简单, 把UIButton的Type 设置成Custom 就可以了!
验证码倒计时
验证码倒计时
self.timer=[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(CountTime) userInfo:nil repeats:YES];
/** * 验证码倒计时 */ -(void)CountTime{ if (self.countdownnumber>=0) { NSString *str=[NSString stringWithFormat:@"%d秒",self.countdownnumber]; [self.getCaptchaButton setTitle:str forState:UIControlStateNormal]; self.countdownnumber--; } else { [self.timer invalidate]; self.getCaptchaButton.userInteractionEnabled=YES; self.getCaptchaButton.backgroundColor = BTN_YES_COLOR; [self.getCaptchaButton setTitle:@"获取验证码" forState:UIControlStateNormal]; } }
相关文章推荐
- ios 大图 真机不显示的问题
- iOS NSString的常用用法
- iOS设计模式——Category
- iOS图片高斯模糊 毛玻璃效果
- IOS OC声明变量在@interface括号中与使用@property的区别(转载)
- iOS开发之NSRunLoop概述
- iOS导航栏返回按钮
- iOS 用 AVPlayer 播放一个本地音频文件
- ios import和@class的区别
- iOS多线程之NSThread
- ios 自适应高度
- ios多级跳动
- iOS如何在一个view上 显示两个tableview
- iOS开发中的键盘高度变化处理
- iOS 给category添加属性的小技巧
- iOS持久化之CoreData(待总结)
- iOS持久化之plist(待总结)
- iOS抽屉效果、二级菜单(点击,拖拽滑动)
- iOS中Json解析的四种方法
- iOS - 小方法