2012-11-02 5 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는 전적으로 렌더링 기술입니다. 상호 작용을 처리하지 않습니다. 태핑 가능한 단어가 필요한 경우 직접 구현해야합니다. 아마 이미 그것을하는 제 3 자 라이브러리가 있습니다. –

+0

안녕하세요, 케빈, 관심을 가져 주셔서 감사합니다. – stefanosn

+0

Google을 최대한 활용할 수 있다고 확신합니다. –

답변

0

많은 자원이 거기 밖으로, 여기 하나 Hyperlink in coretext

당신은 당신이 만들고 싶어 단어/섹션의 경계를 찾기해야 할 일은 탭을 처리하는 범위 내에서 하위보기를 추가 할 수 있습니다. 희망이 도움이됩니다!