here과 같은 종류의 다른 단어에 다른 스타일의 "라벨"을 만들려고합니다. 문제는 - 내가 볼 수있는 한 - UATextLayer의 MonoTouch 구현은 String 속성에 유형 문자열이 있으므로 String 속성에 NSAttributedString을 할당하는 것을 허용하지 않습니다.MonoTouch에 AttributedString이있는 CATextlayer
구현에 오류가 있습니까? 아니면이 방법이 다른가요?
(예, 별도의 라벨을 추가 할 수 있음을 알고 있습니다. 그러나 더 나은 해결책이있는 경우에는 그렇지 않을 것입니다.) (미구엘의 대답에 응답)
이편집 : 대신 "void_objc_msgSend_IntPrt"이 질문에 대해 코드는 GetHander로 변경하고이 "void_objc_msgSend_IntPtr을"수정 후
컴파일 및 실행,하지만 잘 작동을하지 않습니다 어쨌든 (나는 대답으로 표시하는 것이 약간 빠름). 오류는 발생하지 않지만 텍스트는 표시되지 않습니다.
코드 :
string _text="Example string";
if(_textLayer==null) {
_textLayer = new CATextLayer();
_textLayer.Frame = new RectangleF(50,698,774,50);
_textLayer.Wrapped=true;
_textLayer.ForegroundColor=UIColor.White.CGColor;
_textLayer.BackgroundColor=UIColor.Clear.CGColor;
Layer.AddSublayer(_textLayer);
}
//_textLayer.String=_text;
CTFont _font=new CTFont("MarkerFelt-Thin",48);
CTStringAttributes _attrs=new CTStringAttributes();
_attrs.Font=_font;
_attrs.ForegroundColor = UIColor.White.CGColor;
var nsa = new NSAttributedString(_text);
Messaging.void_objc_msgSend_IntPtr(
_textLayer.Handle,
Selector.GetHandle("string"),
nsa.Handle);
나는 텍스트를 볼 (그러나 물론 속성 제외) _textLayer.String=_text
의 주석, 그래서 문제가 층이 아닌 경우.
sel_registerName이 비공개이며 다른 클래스에서 호출 할 수없는 것 같습니다. 뭔가 빠졌습니까? – Johan
... 나 자신을 알게되었습니다 : Selector.GetHandle ("string") – Johan
작동에 익숙하지 않기 때문에 추가 도움말을 위해 제 질문을 수정했습니다 ... – Johan