---
title: "iOS 富文本控件"
author: "374016526"
date: "2014-04-25T15:24:27Z"
tags: ["iPhone", "富文本"]
categories: ["移动开发"]
slug: "ios"
draft: false
lastmod: "2014-04-25T15:24:27Z"
id: 2054589
url: "https://374016526.iteye.com/blog/2054589"
---

使用方式:

NSString \*t = \[NSStringstringWithFormat:@"&lt;a href=http://www.baidu.com &gt;&lt;font size = 22 color=#001100&gt;百度 &lt;/font&gt;&lt;/a&gt;"];

 

    RTLabelComponentsStructure \*componentsDS = \[RCURLLabelextractTextStyle:t];

    RCURLLabel \*contentlbl = \[\[RCURLLabel alloc] initWithFrame:CGRectMake(10, 10, 300, 10)];

    contentlbl.componentsAndPlainText = componentsDS;

    \[self addSubview:contentlbl];

    

    CGSize optimumSize = \[contentlbl optimumSize];

    CGRect frame = \[contentlbl frame];

    frame.size.height = (int)optimumSize.height;

 

    \[contentlbl setFrame:frame];