Latest 0.0.3
Homepage https://github.com/Lemon365189523/LMAttributedString
License MIT
Platforms ios 7.0, requires ARC
Authors

LMAttributedString是一个函数式编辑富文本的库

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

CovoaPods

使用CocoaPods LMAttributedString融入您的Xcode项目,在你指定它在你的Podfile。

pod 'LMAttributedString'

关于怎么使用

先创建一个LMAttributedString对象,[LMAttributedString creatAttrubutedString],然后调用setAttributes:的方法。该方法是一个block里面有个LMAttributeWorker对象,用该对象来设置文本和效果。一个worker只操作对应设置的文本。
操作完毕把LMAttributedString对象里的string属性设置到UIlable或其他控件中label.attributedText = attribute.string;

效果图
效果图01

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)];
}];

效果图02

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]];

}];

该库是刚刚开始写,很多地方需要优化,希望大家能给点意见,和那些地方不好也希望提点。

Latest podspec

{
    "name": "LMAttributedString",
    "version": "0.0.3",
    "summary": "u4e00u4e2au51fdu6570u5f0fu7684u5bccu6587u672cu5e93",
    "description": "this project provide all kinds of categories for iOS developer",
    "homepage": "https://github.com/Lemon365189523/LMAttributedString",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "platforms": {
        "ios": "7.0"
    },
    "authors": {
        "KADFWJ": "[email protected]"
    },
    "source": {
        "git": "https://github.com/Lemon365189523/LMAttributedString.git",
        "tag": "0.0.3"
    },
    "source_files": [
        "Classes",
        "LMAttributedString/Classes/*.{h,m}"
    ],
    "requires_arc": true
}

Pin It on Pinterest

Share This