BBAAttributedStringMaker.h 1.59 KB
//
//  BBAAttributedStringMaker.h
//  
//
//  Created by linling on 15/6/27.
//  Copyright (c) 2015年 baidu. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "BBAAttibutedStringAttribute.h"

@interface BBAAttributedStringImgAttachment : NSObject

@property (nonatomic, strong) UIImage *img;
@property (nonatomic, assign) CGRect bounds;

@end

/**
 *  字符串属性渲染器
 */
@interface BBAAttributedStringMaker : NSObject

/**
 *  待渲染的字符串
 */
@property (nonatomic, copy) NSString *needRenderString;

#pragma mark - Render Attributed
- (BBAAttibutedStringAttribute *(^)(UIColor *))color;
- (BBAAttibutedStringAttribute *(^)(UIFont *))font;
- (BBAAttibutedStringAttribute *(^)(NSTextAlignment))alignment;
- (BBAAttibutedStringAttribute *(^)(CGFloat))lineSpace;
- (BBAAttibutedStringAttribute *(^)(NSLineBreakMode))lineBreakMode;
- (BBAAttibutedStringAttribute *(^)(CGFloat))wordSpace;
- (BBAAttibutedStringAttribute *(^)(NSInteger))underline;

#pragma mark - Specify Attributed Range
- (void(^)(NSRange, void(^)(BBAAttributedStringMaker *)))range;
- (void(^)(NSString *, void(^)(BBAAttributedStringMaker *)))subString;
- (void(^)(NSUInteger, void(^)(BBAAttributedStringMaker *)))fromIndex;
- (void(^)(NSUInteger, void(^)(BBAAttributedStringMaker *)))toIndex;
- (void(^)(NSRegularExpression *, void(^)(BBAAttributedStringMaker *)))regular;

#pragma mark - UIImage attachment
- (void)imageMapWithReg:(NSRegularExpression *)expression
                matcher:(BBAAttributedStringImgAttachment *(^)(NSString *codeString))matcher;

#pragma mark - Render
- (NSAttributedString *)makeRender;

@end