2014-02-13 2 views
1

사용하지 않는 코드 drawInRect : r withFont :을 (를) 사용하는 라이브러리 (SGInfoAlert)를 사용하고있었습니다. iOS 7에서 일부 코드를 수정하려고 시도했지만 텍스트가 표시되지 않습니다. 왜 이런 일이 일어나는 지 아는 사람이 있습니까? 여기 drawInRect : withFont : iOS 7이 작동하지 않습니다.

// Changed this 
//[info_ drawInRect:r withFont:[UIFont systemFontOfSize:kSGInfoAlert_fontSize]]; 

// To this 
NSDictionary *textAttributes = @{NSFontAttributeName: [UIFont systemFontOfSize:kSGInfoAlert_fontSize]}; 

[info_ drawInRect:r withAttributes:textAttributes]; 

https://github.com/sagiwei/SGInfoAlert

답변

5

확인 자식 저장소이다. 나는 고침을 발견했다.

// iOS 7 fix 
UIFont* font = [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline]; 

NSDictionary *attrs = @{ NSForegroundColorAttributeName : [UIColor whiteColor], 
         NSFontAttributeName : font, 
         NSTextEffectAttributeName : NSTextEffectLetterpressStyle}; 


[info_ drawInRect:r withAttributes:attrs]; 
+0

"NSTextEffectAttributeName"매개 변수가 필요한 이유는 누구나 알고 계십니까? 설정하지 않으면 코드에 크래시가 발생합니다. 그래도 제대로 작동하지만 가능한 유일한 값은 NSTextEffectLetterpressStyle입니다. 실제로는 원하지 않습니다. –