文章来源:淘论文网   发布者: 毕业设计   浏览量: 26

定做请加QQ:1052602713 或加微信:


还可以点击去查询以下关键词:
[Scott]    [定制]    [Counter]    [Scott定制Counter]   

项目介绍:

ScottCounter 简介

一款优雅地显示数字、金额动态变化的控件,论文开题报告,支持UILabel和UIButton。

特点:

支持UILabel/UIButton数字加减动画显示;

支持设置一般文本属性以及富文本显示;

支持四种时间曲线函数动画;

支持自定义的数字格式;

Requirements 要求

Xcode 8+

iOS 7.0+

ARC / MRC

How to use 如何使用安装方式

手动安装:
下载Demo后,将子文件夹ScottCounter拖入到项目中,导入头文件 ScottCounter.h 即可。

CocoaPods安装:

pod search ScottCounter

在podfile里面添加pod 'ScottCounter', '~> 版本号'

pod install

代码使用UILabel

设置一般字体属性

[self.label1 scott_fromNumber:0 toNumber:100 duration:1.5f format:^NSString *(CGFloat number) { return [NSString stringWithFormat:@'%.2f', number]; }];

设置富文本字体属性

[self.label2 scott_fromNumber:0 toNumber:100 duration:1.5f animationOptions:options attributedFormat:^NSAttributedString *(CGFloat number) { NSString *string = [NSString stringWithFormat:@'%.2f%%',number]; NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:string]; // 设置字体属性 NSRange range = [string rangeOfString:[NSString stringWithFormat:@'%.2f',number]]; [attributedString addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:22],NSForegroundColorAttributeName:[UIColor brownColor]} range:range]; return attributedString; } completion:^{ self.label2.textColor = [UIColor redColor]; }];UIButton

设置一般字体属性

[self.btn1 scott_fromNumber:0 toNumber:100 duration:1.5f format:^NSString *(CGFloat number) { return [NSString stringWithFormat:@'%.2f', number]; }];

设置富文本字体属性

[self.btn2 scott_fromNumber:0 toNumber:100 duration:1.5f animationOptions:options attributedFormat:^NSAttributedString *(CGFloat number) { NSString *string = [NSString stringWithFormat:@'%.2f%%',number]; NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:string]; // 设置字体属性 NSRange range = [string rangeOfString:[NSString stringWithFormat:@'%.2f',number]]; [attributedString addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:22],NSForegroundColorAttributeName:[UIColor brownColor]} range:range]; return attributedString; } completion:^{ NSAttributedString *attr = [self.btn2 attributedTitleForState:UIControlStateNormal]; NSMutableAttributedString *mAttri = [[NSMutableAttributedString alloc] initWithAttributedString:attr]; NSRange range = NSMakeRange(0, attr.length); [mAttri addAttributes:@{NSForegroundColorAttributeName: [UIColor redColor]} range:range]; [self.btn2 setAttributedTitle:(NSAttributedString *)mAttri forState:UIControlStateNormal]; }];

注意点:

需要把UIButton设置自定义模式,不然会出现一闪一闪的效果;

如果在UIButton设置富文本标题之后,完成回调里面不能简单地使用[self.btn2 setTitleColor:[UIColor redColor] forState:UIControlStateNormal];来更改字体颜色;

联系

如果你发现有bug,欢迎提issue

如果你需要帮忙拓展,欢迎提issue

如果你想为代码做贡献,欢迎联系。


这里还有:


还可以点击去查询:
[Scott]    [定制]    [Counter]    [Scott定制Counter]   

请扫码加微信 微信号:sj52abcd


下载地址: http://www.taolw.com/down/6653.docx
  • 上一篇:iOS 一个轻量级的标签和列表定制多项选择互动,标签和列表可拆...
  • 下一篇:ScottP毕业设计ageView