Skip to content

轻量级,文本加自定义边框背景转换成图片,常用于富文本特殊字符加圆角边框背景

License

Notifications You must be signed in to change notification settings

dayu1213/YHDrawImage

 
 

Repository files navigation

YHDrawImage

轻量级,文本加自定义边框背景转换成图片,常用于富文本特殊字符加圆角边框背景

CI Status Version License Platform

Features

示例

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

YHDrawImage is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'YHDrawImage', :git => 'https://github.com/yelinux/YHDrawImage.git'

Or drag the YHDrawImage/Classes folder into your project.

Usage

  1. Add the following to your view controller file:
#import "YHDrawImage.h"
  1. Create an instance object of YHDrawModel and draw:
UIImage *img1 = YHDrawModel.new
    .string(@"V", @{NSForegroundColorAttributeName:UIColor.whiteColor, NSFontAttributeName:[UIFont boldSystemFontOfSize:10]})//文本+属性
    .fill(color)//背景颜色
    .radius(2, UIRectCornerAllCorners)//圆角
    .size(CGSizeMake(15, 15))//固定宽高
    .draw;
UIImage *img = YHDrawModel.new
    .attributes(attr)//文本
    .fill(UIColor.whiteColor)//背景颜色
    .stroke(color, 1)//边框颜色,边框宽度
    .radius(2, UIRectCornerAllCorners)//圆角
    .padding(0, 6, 0, 4)//内边距
    .size(CGSizeMake(0, 15))//固定宽高,0表示不固定,随内容自适应
    .margin(0, 1, 0, 1)//外边距
    .draw;//绘制

Author

WeChat:chenyehong666888, E-mail:[email protected]

License

YHDrawImage is available under the MIT license. See the LICENSE file for more info.

About

轻量级,文本加自定义边框背景转换成图片,常用于富文本特殊字符加圆角边框背景

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Objective-C 91.7%
  • Ruby 8.3%