Xamarin.iOS将左图像添加到UILable

Xamarin.iOS将左图像添加到UILable,xamarin.ios,uilabel,Xamarin.ios,Uilabel,这是我的例子,我有一个自定义控件,它是UILable固有的 我需要创建拍摄图像的方法(从代码或故事板) 添加到我的标签中 My尝试将此代码转换为Xamarin.iOS 任何人都可以帮我试试这个: public void SetLeftDrawable (UIImage image) { var attachment = new NSTextAttachment (); attachment.Image = image; var attachmentString = NSA

这是我的例子,我有一个自定义控件,它是UILable固有的 我需要创建拍摄图像的方法(从代码或故事板) 添加到我的标签中

My尝试将此代码转换为Xamarin.iOS

任何人都可以帮我试试这个:

public void SetLeftDrawable (UIImage image)
{
    var attachment = new NSTextAttachment ();
    attachment.Image = image;
    var attachmentString = NSAttributedString.FromAttachment (attachment);
    //replace "price" with your string.
    var myString = new NSMutableAttributedString ("price");
    myString.Append (attachmentString);
    AttributedText = myString;
}
希望这有帮助。-

试试这个:

public void SetLeftDrawable (UIImage image)
{
    var attachment = new NSTextAttachment ();
    attachment.Image = image;
    var attachmentString = NSAttributedString.FromAttachment (attachment);
    //replace "price" with your string.
    var myString = new NSMutableAttributedString ("price");
    myString.Append (attachmentString);
    AttributedText = myString;
}
希望这有帮助-