LMAttributedString 0.0.4

LMAttributedString 0.0.4

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布上次发布2018年3月

lemon-fan维护。



  • 作者:...
  • KADFWJ

编写这个库的原因是在学习 ReactiveCocoa 的时候,理解了关于函数式编程思想的一点点,所以写的比较简陋,望见谅。

### 使用 CocoaPods 将 LMAttributedString 集成到您的 Xcode 项目中,在您的 Podfile 中指定它。

pod 'LMAttributedString'

### 使用说明 首先创建一个 LMAttributedString 对象,使用 [LMAttributedString createAttributedString],然后调用 setAttributes: 方法。该方法是一个 block 包含一个 LMAttributeWorker 对象,使用该对象来设置文本和效果。一个 worker 只操作相应设置的文本。 操作完成后,将 LMAttributedString 对象的 string 属性设置到 UILabel 或其他控件中 label.attributedText = attribute.string;

效果图 屏幕快照 2017-03-30 下午2.33.22

LMAttributedString *attribute = [[[[LMAttributedString creatAttrubutedString] setAttributes:^(LMAttributeWorker *worker) {
   [worker setString:@"my "];
   [worker setFont:[UIFont fontWithName:@"futura" size:20.0]];
   [worker setTextColor:[UIColor redColor]];
   [worker setBackgroundColor:[UIColor greenColor]];
   [worker setLigature:LMOtherLigature];
}]appendAttributes:^(LMAttributeWorker *worker) {
   [worker setString:@"name is"];
   [worker setFont:[UIFont fontWithName: @"futura" size: 30]];
   [worker setTextColor:[UIColor blueColor]];
   [worker setLigature:LMTextNotLigature];
   [worker setSpace:3];
}] appendAttributes:^(LMAttributeWorker *worker) {
   [worker setString:@"Lemon"];
   [worker setShadow:CGSizeMake(0, 1) andRadius:5 andColor:[UIColor greenColor]];
   [worker setLink:@"www.baidu.com"];
   [worker setFont:[UIFont systemFontOfSize:15]];
   [worker setBaselineOffset:-10];
   [worker setObliqueness:0.5];
   [worker setExpansion:-0.5];
   [worker setImage:@"lemon" andBounds:CGRectMake(0, 0, 30, 30)];
}];

屏幕快照 2017-03-30 下午2.43.59

LMAttributedString *attribute = [[LMAttributedString creatAttrubutedString] setAttributes:^(LMAttributeWorker *worker) {
   [worker setString:@"写这个库的原因是在学习ReactiveCocoa时候,理解了那么一定点的关于函数式编程的思想而写的。"];
   [worker setlineSpacing:4];
   [worker setlineBreakMode:NSLineBreakByCharWrapping];
   [worker setTextAlignment:NSTextAlignmentRight];
   [worker setUnderlineStyle:NSUnderlineStyleThick andColor:[UIColor whiteColor]];
   [worker setStrokeWidth:3 andColor:[UIColor purpleColor]];
   
}];

该库刚刚开始编写,很多地方需要优化,希望大家能提出意见,以及对哪些地方不好也能提点。