UITextView의 레이아웃 매니저에 대한 액세스 권한을 얻을 수있는 방법 텍스트 편집으로 클라이언트는 사용자 정의 스타일을 추가 할 수 있도록, 그 NSLayoutManager 노출이되어 (http://www.objc.io/issue-5/getting-to-know-textkit.html 예를 들어,이 문서는 구문 강조와 UITextView를 구현) 비슷한 사용자 지정을 허용하도록 UITextField에 대한 기본 NSLayoutManager를 가져 오는 방법?는, UITextField
1
A
답변
-1
textView.layoutManager
으로 레이아웃 관리자에 액세스 할 수 있습니다. 당신은 모든 객체를 직접 작성하여 자신의 레이아웃 매니저를 할당 할 수
NSTextStorage* textStorage = [[NSTextStorage alloc] initWithString:string];
// you could create a subclass of NSLayoutManager here
NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init];
[textStorage addLayoutManager:layoutManager];
self.textContainer = [[NSTextContainer alloc] initWithSize:self.view.bounds.size];
[layoutManager addTextContainer:self.textContainer];
UITextView* textView = [[UITextView alloc] initWithFrame:self.view.bounds textContainer:self.textContainer];
[self.view addSubview:textView];
을 당신은 내가 걸릴 접근하지 구문 강조를 할하려는 그러나 경우. 나는 사용자가 변경 사항을 감지하는 UITextView
을 서브 클래스 및
[self.storage addAttributes:range:]
를 통해 그 시점에서 강조 자신의 구문을 추가 제안 : https://github.com/abhibeckert/Dux/blob/master/Dux/DuxSyntaxHighlighter.m - 그것은 적용 다양한 언어에 대한 성능과 지원이 뛰어난 NSTextStorage로 구문 강조 표시.
0
Apple은 다양한 이유로 UILabel
의 layoutManager를 노출하지 않습니다. 그 이유는 레이블 텍스트를 편집하지 않고 범위가 변경 될 때와 같이 드물게 레이아웃하기 때문에 여러 레이블간에 실제로 공유된다는 것입니다.
하지만 당신은 내가 여기에 보여처럼 UILabel
는, 스택 TextKit 사용자 정의를 사용할 수 있습니다 : 질문이 아니었다 https://www.cocoanetics.com/2015/03/customizing-uilabel-hyperlinks/
관련 문제
- 1. UITextField 내부의 UITextField 키보드를 한 번에
- 2. Validate UITextField
- 3. UITextField autocomplete
- 4. 의 UITextField
- 5. UiTextField 이벤트
- 6. UITextField resignFirstResponder
- 7. UITextField 포커스
- 8. 아이폰의 UITextField
- 9. NavigationController UITextField
- 10. UITextField sublayer
- 11. UITableViewCell의 UITextField
- 12. UITextField becomeFirstResponder
- 13. 수신자에게 UITextField
- 14. UITextField bind
- 15. UITableViewCell의 UITextField
- 16. UITextField 타원
- 17. 의 UITextField
- 18. Animate UITextField
- 19. 데이터로드 uitextfield
- 20. 프로그램 생성 할 수 없습니다의 UITextField 편집 (아이폰 OS)는
- 21. UITextField - 다음 버튼
- 22. UITextField 메시지가 수신되지 않음
- 23. UITextField -resignFirstResponder 실패
- 24. 버튼 클릭시 UItextfield 추가
- 25. 의 UITextField - 왼쪽 자리
- 26. touchesBegan 최적화 UITextField
- 27. UITlertController의 UITextField 유효성 검사
- 28. 함수에 전달할 UITextField 식별
- 29. 의 UITextField Crazyness
- 30. UITcrollVew의 UITextField 및 UILabel
. 문제는 UITextField의 layoutManager에 액세스 할 수 있는지 여부입니다. – ldoogy