2012-11-02 24 views
0

假設我有一個CoreText NSMutableAttributedString用這句話:「繼續閱讀」Coretext使一部分nsmutableattributtedstring聯

我要打的第一個字「繼續」點擊,這樣我可以點擊它,並顯示負載另一個UIView。我已經找到了如何將它加下劃線並將顏色更改爲藍色,但我怎樣才能使它可以鏈接。任何示例?

這是我的代碼,它使下劃線和前景色爲藍色。

CFAttributedStringSetAttribute(string, CFRangeMake(0, 10),kCTForegroundColorAttributeName, [UIColor blueColor].CGColor); 
      SInt32 type = kCTUnderlineStyleSingle; 

CFNumberRef underline = CFNumberCreate(NULL, kCFNumberSInt32Type, &type); 
CFAttributedStringSetAttribute(string, CFRangeMake(0, text.length),kCTUnderlineStyleAttributeName, underline); 
CFAttributedStringSetAttribute(string, CFRangeMake(0, text.length),kCTUnderlineColorAttributeName, [UIColor blueColor].CGColor); 

感謝

+0

CoreText純粹是一種渲染技術。它不處理交互。如果你需要可點擊的單詞,你需要自己實現。那裏可能有一個第三方庫,但它已經做到了。 –

+0

嗨凱文,謝謝你的興趣...請任何例子。 – stefanosn

+0

我相信你可以儘可能地使用Google。 –

回答

0

有很多資源在那裏,其中一個是 這裏找到Hyperlink in coretext

你需要做的是找到你想字/段的邊界可點擊,並在處理水龍頭的邊界內添加子視圖。希望能幫助到你!